Strategies for loading scripts in your HTML page

As developers we know that loading scripts makes our page render slowly. The problem with scripts is that they can call document.write(), which will potentially modify the DOM. That is why browsers must fetch the script and execute it right away, while the rest waits. One technique to cope with that is to move all your scripts to the end of your <body>. By doing this you let the browser render the entire HTML page along with the CSS styles first and then execute the scripts. This is only possible, of course, if your scripts do not make any changes to the DOM by calling document.write().

Continue Reading…