0
How to change order load of .js file on PlayCode
Scripts are loading before page is ready when I use separate .js file and gives error. It's forcing me to put all the scripts inline on .html file. How can I change loading order of files. Compare these codes https://code.sololearn.com/W84l3fCxUDdw/?ref=app https://code.sololearn.com/WyCxo6564uBU/?ref=app
2 Respostas
+ 2
You can use "window.onload" in the JS file to run JS code only after the HTML file has loaded.
For instance:
window.onload = function() {
// Your whole code inside here.
}
Code example:
https://code.sololearn.com/WntPX8EKXEqh/?ref=app
+ 1
Thank you