Javascript location

Javascript location, a forum discussion on Jojo CMS. Join us for more discussions on Javascript location on our General Discussion forum.

Back to Forum Index : Back to General Discussion   RSS
Jaijaz Jaijaz

19 Nov 2010
Posts: 215

I'm currently taking a look at Boilerplate as I wanted to see what all the hype was about.

So one thing they are doing, and I've heard this a lot lately, is put the javascript at the bottom. The theory is that this provides faster page loads.

I'm curious if anyone has played with Javascript location and whether they think it makes enough of a difference to care?

Jai
If you not living on the edge you taking up too much space.
Rick Rick

21 Nov 2010
Posts: 336

There's lots of stuff in the boiler plate that could be integrated into Jojo. I haven't looked into the Javascript placement though. The local fallback for the Google hosted Javascript is nice. I've seen a better one for that or CSS somewhere nut can't remember or find it again.
Jaijaz Jaijaz

21 Nov 2010
Posts: 215

Actually I have decided I amgoing to make a Jojo theme boilerplate. I'll submit it somehow when I'm done. I really lovin the graceful degrades and the CSS resets.
If you not living on the edge you taking up too much space.
tom

Developer

tom

22 Nov 2010
Posts: 379

I've been playing with adding it to the core locally - a few things are problematic to implement.

Adding Modernizr and altering the head to include the html tag additions is pretty straightforward - so for that side of it, combining everything into a single css file is easy enough to do and cleaner than the current method of customhead conditional links.

Changing the doctype to html provokes screeds of errors if you're using a validation checker like the HTML Validator addon for Firefox (but is fine if using the beta W3C validator) but is something we should be aiming for in any case I'm thinking.

Moving most scripts to the bottom is also pretty easy - a lot of plugins are currently using the customhead hook to add scripts and they just need to switch to the 'foot' hook in api.php

But with many plugins generating inline content scripts (which is bad in itself of course and something I've probably more guilty of than anyone), I've found that moving jQuery to the foot just breaks too much.

I'm reluctant to move analytics there by default either, although it could be an option (at the moment I think if you choose 'async' the top/bottom option is ignored) for those that aren't doing anything other than pagetracking and are not fussed about the possibility of missing those with superspeedy clickthroughs.

The .htaccess stuff is mostly over my head, but looks interesting...
tom

Developer

tom

4 Dec 2010
Posts: 379

The current svn version of branch now has a bunch of html5-friendly options (under Site) for:
* changing the doctype to html
* adding boilerplate browser conditionals to the html tag
* adding the modernizr script
* using boilerplate css reset
* using modernizr css
* moving the common.js and jquery.js script calls from the head to the foot
* moving the async version of Google analytics to the foot (the option was there before but was ignored for the async version)

The head and foot templates have also been tightened up a good deal.

It does make the page content load significantly snappier, and without any downside for those sites that aren't really using scripts anyway.

For those that are, there are a lot of plugins that have in-line code which will break if jQuery and/or common.js move to the foot but I'm trying to weed these out and update them as I find them.
Back to Forum Index : Back to General Discussion   RSS
You must be logged in to post a reply



You need to Register or Log In before posting on these forums.