There are two main reasons for placing CSS before JavaScript.
-
In older browsers (Internet Explorer 6-7, Firefox 2, etc.), initiating a script download blocks all subsequent downloads. Therefore, if you place
a.jsbeforeb.css, they will be downloaded sequentially: firsta.js, thenb.css. If you placeb.cssbeforea.js, they will be downloaded in parallel, resulting in faster page load times. -
No content is rendered before all style sheets are downloaded—this holds true across all browsers. Scripts differ in that they block the rendering of all DOM elements below the script tag. Placing scripts in the HEAD means the entire page is blocked from rendering until all style sheets and all scripts are downloaded. While blocking rendering for style sheets is sensible (to ensure immediate correct styling and avoid flash of unstyled content), blocking the entire page for scripts is unnecessary. Typically, scripts affect only specific DOM elements or parts of them. It is better to load scripts as low on the page as possible, or load them asynchronously.
Creating examples with Cuzillion is interesting. For instance, the page at http://stevesouders.com/cuzillion/?c0=hj1hfff2_0_f has a script in its HEAD, so the entire page remains blank until the download completes. However, if you move the script to the end of the BODY block, the page title will render because these DOM elements appear above the SCRIPT tag, as seen on this page.