So, I have to load these in the main page
jQuery.js
jQueryMobile.css
jQueryMobile.js
mainScript.js
But if the user enters from anywhere else I need to load them dynamically. so I have
scriptCheck.js
if scripts not present
//create array of elements containing above files
scriptsArray.forEach do |script|
head.append(script)
end forEach
end if
My question is, is there a way to make the loading a synchronous operation, that waits for each script to load and be interpreted before loading the next one?