HTML5 : Synchronous XMLHttpRequest on the main thread is deprecated warning

Im getting this warning when loading
coming from : frameworks/cocos2d-html5/CCBoot.js:781

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/

Also getting this when doing cocos run -p web, but its also giving me the error “Uncaught TypeError: Cannot read property ‘style’ of null” on CCBoot.js:729 that causes my app to not start :confused:

It seems like the canvas element in CCBoot.js is null due to something not loading correctly. How can I go about solving this problem?

Edit the index.html file such that the script for cocos2djs (or ccboot.js) is included at the end of the body rather than in the . When included in the head, the current version of cocos tries to make changes to the DOM even beofre its ready.

@Nambiar
Thanks but it does’t work
Well according to documentation
and google it is chrome thing when setting xhttp open async to false …
changing it to true , give other errors

Oh my reply was meant as a solution to @Benzilla 's problem. :slight_smile: The deprecation warning is something i’m not really sure about.

This warning is given on loading project.json if you put the content of project.json into document[“ccConfig”] it won’t try to load it and you wont get the warning.
in your html put something like this using the content of your own project.json:

<script id=“ccConfig”>
(document[“ccConfig”] = {
“project_type”: “javascript”,

    "debugMode" : 1,
    "showFPS" : true,
    "frameRate" : 60,
    "noCache" : false,
    "id" : "gameCanvas",
    "renderMode" : 0,
    "engineDir":"frameworks/cocos2d-html5",

    "modules" : ["cocos2d","ccui"],

    "jsList" : [
        "src/resource.js",
        "src/app.js"
    ]
});

</script>

1 Like