Home
Do You Place Scripts at the Bottom of Your Page?
  v4.0 Posted at 24/08/2015 11:08 AM by William Yin
Bear in mind that the load time is a very important aspect on web development. The goal is to make the page load as quickly as possible for the user.

It's known that when a browser loads a script, it can’t continue on until the entire file has been loaded.

Once JavaScript files have the purpose to add functionality — something happen after a button is clicked for example — there is no good reason to load the JS file before the button itself.

So go ahead and place JS files at the bottom of the HTML, just before the closing body tag.

<script type="text/javascript" src="file.js"></script>
</body>
</html>

Figure: Place JavaScript at the bottom of your HTML

Tests at a big online sales company revealed that every 100 ms increase in load time decreased sales by 1%.

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments:

    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.