SimpleMachines/SMF2.1 — pull request #63 by marcusforsberg (2012-07-11 18:00:51+00:00)
Title: CSS/JS loading functions in the source

Spent some time updating loadCSSFile() and loadJavascriptFile() to make them more useful. Added a couple of more functions to handle JS, and moved some common stuff out of index.template.php and into the sources since they're not really per-theme (JQuery and script.js, for example).

addInlineJavascript() and addJavascriptVar() are essentially just updating their respective entry in $context, so they're very small and really just wrappers, but it makes it a little cleaner and saves a few seconds for modders.

I didn't go as far as to moving the standard CSS files out of index.template.php even though that could be done since they're essentially the same in all themes, and if a theme should want to use style.css or whatever instead of index.css, they could just edit $context['css_files'] in template_init(). That's up for discussion!

Something we may also want to consider is moving ALL the default JS files to the bottom of the HTML ($options['defer'] = true in loadJavascriptFile()) as well as maybe adding the HTML5 async attribute to external scripts for browsers that support it ($options['async'] = true in loadJavascriptFile()). This would be for the sake of page loading times.