Some time ago (almost 1 month ago) I created an RFC proposing to usage of defer in all script tags in phpbb.
The reason behind this is actually very simple. Reduce significantly the loading time of the page (time passed from the page request until the "load" or "onload" event).
By the HTML (3,4 and 5) spec, while loading a page, when a script tag is found all page processing should stop and the script should be downloaded and executed before continuing the processing of the page. In a idea to solve this problem, IE introduced the @defer attribute which meant to solve this problem. The HTML4 picked this up and introduced defer in HTML4. Unfortunately the HTML4 spec does not define what should be done when defer is found. According the the w3c (HTML4) the defer is just a clue that the browser can continue parsing the page and execute the script later. All browsers follow the HTML4 spec about defer. Each implement their way.
Webkit (chrome, chromonium, safary...) and gecko (firefox, etc...) implement the same way. Load the scripts immediately and execute them just before the load event. It was also allowed for inline script tags.
Trident (IE) implements in such way that scripts are seperated in 3 categories, inline defered, same origin external defered and other origin external defered. I've never found the order they execute between them but, for each group, they are executed the same order they appear in the page.
Presto (Opera) also took another approach dealing with defer that is also valid against HTML4's spec. It just ignores defer all together. There's the "hidden" option "Delayed Script Execution" in about:config but it's still experimental so it does not count.
At the moment only Trident 6.0 (IE10), gecko and webkit (any still supported version on both) support defer according to HTML5's spec.
Trident <6.0 (IE<10) follows the same rule for the previous versions. Opera still ignores the @defer.
With so many troubles... why use defer?
Well, IE has the <![if !IE]> and <!-- <![if IE]--> we can have the only other origin script (jQuery) load without defer for IE and for the other scirpt tags apply to IE the same way we apply the other browsers. IE has it's uncomplicated fix. All scripts are deferred except for the external jQuery.
Opera ignores defer, so if we assume that the script tags have and don't have defer. This can easily be solved using jQuery's $(document).ready() method or the DOMDocumentLoaded in addEventListener() (or the later load/onload event).
Also gecko + webkit are the owners of about 60% of the browser share (data from december 2011) and gecko + webkit + trident have about 90% of the browser share.
What do you have to say? Should we implement or not implement?
Another problem. Some recommendations say scripts should be placed at the bottom of the page. The rationale behind this is simple:
Entertain the user with the CSS and HTML of the page and let each script, one at a time, load and execute while the user handles the page. This has a disadvantage. While all that is happening, if the user tries to do something that requires scripting it's unknown whether it will work or not. In my case it's usually frustrating. Using defer in the head just below the CSS we can minimize that.
Using defer always decreases page loading time even if all scripts are cached when there's a need of, at least, one GET access to check if the script was changed (if-modified-since). The problem is that, for opera users (+-12% of the browser share), until opera implements defer, the page will seem to hang while the scripts are being loaded.
My tests say that placing the script tags all the way through the page is the best approach when having multiple .js files with defer and having in account that opera exists (it's the "balance" in action. Unfortunately that balance is hard to implement for phpbb3. So we are resumed to 3 options in which one is a variant of the other. IE will have external jQuery load synchronously.
1.1 Place all script tags in the head with defer (the best option if we lived in a great world where IE followed the current spec and Opera implemented defer)
1.2 Place the jQuery script tag in the head with defer and leave the rest of the tags where they are written in the document with defer (my favorite)
2. Place the jQuery and all the script tags at the bottom without forgetting to use the defer(the best option if defer didn't exist)
No matter which option it chosen, including defer is always the best option according to the tests' results.
So... What do you have to say?
The RFC: viewtopic.php?f=108&t=42497
[EDIT: Removed the scattered word. It can have a different meaning than the one I want to deliver. It's supposed to mean that the script tags are placed in the final code were they are written in the original code. Like what happens many times in the current stable phpbb version]