Javascript – Include your scripts at the bottom of your HTML files

Not so long ago, it was generally considered good practice to insert your Javascript files within the and tags of your html document.

But browsers read html files from top to bottom, and load external files dynamically. Which mean that inserting scripts within the and tags will make your Javascript load before some of the page content.

In order to always load scripts after the content, Javascript files should always been included at the bottom of your html files, as shown below:

    <script src="myscript.js?" type="text/javascript"></script>

Leave a Reply

Your email address will not be published. Required fields are marked *