What is the reason for WInJS being incorporated automatically when developing for Windows 8 in Cordova?

We are currently in the process of developing an application using AngularJS specifically targeting Windows 8. During this development phase, I observed that the generated Visual Studio project included WinJS as a reference even though we were not utilizing WinJS in our app. Consequently, I removed the WinJS reference from the project.

However, after removing WinJS, benign script load errors started appearing in the console while running the app. Upon further investigation, I discovered that cordova.js automatically checks for WinJS and attempts to include it if not found. Here is the relevant code snippet:


var onWinJSReady = function () {
    var app = WinJS.Application;
    var checkpointHandler = function checkpointHandler() {
        cordova.fireDocumentEvent('pause',null,true);
    };

    var resumingHandler = function resumingHandler() {
        cordova.fireDocumentEvent('resume',null,true);
    };

    app.addEventListener("checkpoint", checkpointHandler);
    Windows.UI.WebUI.WebUIApplication.addEventListener("resuming", resumingHandler, false);
    app.start();
};

if (!window.WinJS) {
    // Code snippet for dynamically including WinJS based on platform
} else {
    onWinJSReady();
}

The main question arising from this situation is whether we should keep the WinJS reference and allow Cordova to handle the loading and initialization of WinJS?

Could there be potential conflicts with AngularJS or performance issues in our app by letting Cordova manage WinJS? (The use of var app = WinJS.Application and app.start() within onWinJSReady raises some concerns).

Considering that the app functions correctly without the WinJS scripts, why does cordova.js persist in attempting to include them?

Answer №1

When working with cordova, especially the FileSystem plugin, we noticed that it incorporates elements from WinJS like Promises and Ajax calls. To optimize the app's loading speed, we modified cordova.js by removing all the WinJS components.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for inserting specific characters between JavaScript date values?

In my JavaScript project, I am attempting to adjust the date format to a specific style. The format I aim for is 29-Jan-2021. Currently, with the code below, I can generate "29 Jan 2021": var newDate = new Date('2021-01-29T12:18:48.6588 ...

Locate the highest and lowest values within a .json file

When working on a graph using d3.js, one key step is setting up the scales for the axis. The data for the graph is stored in a Json file with multiple arrays, each representing different regions and years: [{ "id" : "AustraliaNewZealand" , "year" ...

Creating a bower.json file similar to requirements.txt

After diving into the world of bower, I've found it to be incredibly useful. Coming from a python background, I'm accustomed to working with virtualenv and requirements.txt. Given that I prefer not to keep all my dependencies in source control, ...

Optimal technique for implementing up and down arrows in a select dropdown

What's the most effective way to implement a percentage arrow up/down slider/selector within a select element on a webpage like this: https://i.sstatic.net/ygu55.png Should we use a select list with a dedicated background? If so, how do we detect i ...

Express.js using GET request to retrieve all data entries from the database

I am facing a challenge in retrieving specific user data using the GET method on Express.js through a Form. Instead of returning only one user's information, it is currently returning all values when the form is used. Here is the code from index.html ...

Guide to updating the class attribute of an HTML article element using JavaScript

I am working with 6 different styles in CSS and I am trying to apply them randomly using the following code: <script> function getRandom(max) { return "style" + Math.floor(Math.random() * max); } document.getElementById('YYY ...

How to include extra array in serialized form data using jQuery.ajax and retrieve it in PHP?

I am currently searching for an effective method to add extra data, especially an array, to serialized information from a form and be able to retrieve it using PHP later on. Despite numerous attempts, I have not been successful in finding a suitable soluti ...

Pros and Cons of Using HTML5 Mode versus Hash Mode in AngularJS

When using AngularJS 1.3, it is necessary to include the <base> tag in HTML5 mode. This led me to consider the pros and cons of HTML5 mode versus Hash mode. In Hash mode, the major drawback is that URLs can appear unattractive and may not be easy fo ...

AngularJS Router and .NET backend - troubleshooting templateUrl redirections

I am currently working on developing an Angular application that utilizes $routeProvider. The backend of the application is built using .NET, which serves HTML files tailored with specific permissions and roles for my app. Occasionally, when a certain acti ...

"Exploring the World of Asynchronous Programming in Node

Being new to programming with async functions and node.js, I've encountered some challenges. Despite reading a lot on the subject, I'm still facing issues where certain parts of my async code work randomly while others do not. Below is a simplifi ...

Guide to activating "Snapping" feature using the "Select" function in Openlayers 3

I have created an application using OpenLayers 3 that allows users to draw lines or points on a map and add tags to them. While the existing functions in OL3 are helpful for drawing and modifying features, I found it challenging to select the items I drew ...

An effective method for linking a value from one ng-model to another is by identifying and matching a specific string

I have been tasked with binding a value to one model based on the content of another model when it contains a string that starts with "https". For instance, there are two text fields each associated with a different model. <input type="text" ng-model= ...

The NVD3 chart embedded in a React application generates HTML elements that persist on the page indefinitely without fading away

In my React application, I integrated an NVD3 scatter chart. However, I have encountered an issue with the tooltip not disappearing when hovering over the chart: https://i.stack.imgur.com/6lLok.png After moving the cursor away from the chart, the tooltip ...

Understanding the process of globally evaluating classes from files in node.js using the Eval function

Parent script with childscript integration const fs = require('fs'); function includeFile(f) { eval.apply(global,[fs.readFileSync(f).toString()]) } includeFile(__dirname+'/fileToRead.js'); hi(); ...

When a Javascript function returns true/false, it can sometimes result in undefined

Currently, I am facing an issue with my function. Utilizing a MongoDB Database to validate if something exists, the objective is to return false when a data value is true and false otherwise. Up until this point, everything seems to be functioning correct ...

Is there a way to view the contents of the dev server once it has been bundled by webpack?

From my understanding, webpack in dev mode stores all imported files in a certain location and then serves the bundle.js file to the client. If the code inside bundle.js requests a CSS file, the css-loader should have already been configured to provide t ...

Exploring the Power of Arrays, For-Loops, and Functions in JavaScript

Currently, I have a functional code implementation, but I'm struggling with creating a proper loop. I'm seeking a solution to develop a function that changes the URL source of #mainImage to the one in the imgUrl array when hovering over an #id i ...

Expanding Global Object Attributes

As a new JS developer, I've been struggling with a common issue related to the Google Maps API. Despite spending countless hours on StackOverflow, I still can't figure it out. In my code, I use the Google Maps API and I'm trying to assign I ...

Guide to forming an array by extracting specific properties from a nested JSON array using javascript

Currently, I have this list: list = { id: 1, arr: [ {index : 1 , description: "lol" , author: "Arthur"}, {index : 2 , description: "sdadsa" , author: "Bob"}, {index : 3 , desc ...

Guide on successfully importing a pretrained model in Angular using TensorFlow.js

I need help with uploading a pretrained Keras model to my existing tensorflow.js model and then making simple predictions by passing tensors in the correct format. The model is stored locally within the project, in the assets folder. export class MotionAn ...