I am having some problem with the order of javascript execution when I use the content script to inject some javascript into the HTML page:
This is my HTML page I us
JavaScript script tags are not blocking the execution (thankfully!). If you'd like to get the kind of functionality you want (lazy-loading), you'll need to do something like the following:
function loadScript(scriptName, callback) {
var sTag = document.createElement("script");
sTag.src = scriptName;
sTag.onreadystatechange = sTag.onload = function() {
var state = s.readyState;
if (!state || /loaded|complete/.test(state)) {
callback();
}
};
}
This will fire a callback function when the script tag is loaded. From there, load everything and make sure that every callback is processed, then fire your page-load events in the sanity of mind that you have every library you need.