I've encountered an issue while trying to develop an HTML5 game. My goal was to create a modular game by using a JSON file with different modules to load.
Here's the code snippet I attempted
var resources = {};
$.ajaxSetup({
async: false
});
$.getJSON('res/gen/generators.json', function (data) {
resources.generators = data;
});
for (let generator in resources.generators) {
$.getScript("res/gen/" + resources.generators[generator].folder + "/script.js");
}
$.ajaxSetup({
async: true
});
The content of the JSON file
{
"memoryless": {
"folder": "memoryless",
"name": "Memoryless",
"description": "Generates a piece with no regard to the previous history."
}
}
However, I'm facing an error message stating "[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check ." I want to ensure that no other code runs until these scripts are loaded. Any suggestions on how to resolve this?