The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript How to Defer parsing of JavaScript? Reply To: How to Defer parsing of JavaScript?


I’ve been messing around on my own pages with this and came to the conclusion that the defer attribute is a much better option. Using async seems to break document ready with jQuery and is unpredictable for the rest unless it’s a script that could be executed at any time. Instead of just putting the script links in the <head> section (where I like them for overview) and making them render block the rest of the page, giving them the defer attribute seems to work much better. It will have the same effect as putting all links at the bottom of the page. Google PageSpeed seems to like it a lot in any case.

<script defer src=" ... "></script>

Good support as well.

Deferring all scripts that depend on each other, will make them execute in the correct order.