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?