Why is WInJS automatically enabled when setting up Windows 8 in Cordova?

We are developing an application using AngularJS and when we target Windows 8 I noticed that the generated Visual Studio project included WinJS as a reference. Since we are not using WinJS, I just removed the link from the project.

Then I noticed that on launching the application, uninstalling WinJS caused benign script errors when loading the application. Further research showed that cordova.js automatically checks WinJS, and if not, tries to include it (!). Here's the relevant code:

var onWinJSReady = function () {
    var app = WinJS.Application;
    var checkpointHandler = function checkpointHandler() {

    var resumingHandler = function resumingHandler() {

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

if (!window.WinJS) {
    var scriptElem = document.createElement("script");

    if (navigator.appVersion.indexOf("Windows Phone 8.1;") !== -1) {
        // windows phone 8.1 + Mobile IE 11
        scriptElem.src = "//Microsoft.Phone.WinJS.2.1/js/base.js";
    } else if (navigator.appVersion.indexOf("MSAppHost/2.0;") !== -1) {
        // windows 8.1 + IE 11
        scriptElem.src = "//Microsoft.WinJS.2.0/js/base.js";
    } else {
        // windows 8.0 + IE 10
        scriptElem.src = "//Microsoft.WinJS.1.0/js/base.js";
    scriptElem.addEventListener("load", onWinJSReady);
else {


I guess my main question is: Should I leave the WinJS link "as is" and let Cordova load and initialize WinJS?

Could it potentially conflict with AngularJS or reduce the performance of the application in any way? (I think, var app = WinJS.Application

and app.start()

to onWinJSReady

me a bit worried).

Since the app works fine without WinJS script files, why exactly is cordova.js trying so hard to include it?


source to share

1 answer

cordova (and some cordova plugins, especially the FileSystem plugin) use some WinJS features like Promises and Ajax calls. We ended up typing cordova.js and stripping out all the WinJS stuff ... makes the app load much faster!



All Articles