forum.coppermine-gallery.net

No Support => Feature requests => Topic started by: papukaija on June 10, 2010, 09:37:48 am

Title: Move the javascript to the bottom of the document
Post by: papukaija on June 10, 2010, 09:37:48 am
According to Google (http://code.google.com/intl/fi/speed/page-speed/docs/rtt.html#PutStylesBeforeScripts)'s and Yahoo! (http://developer.yahoo.com/performance/rules.html#js_bottom)'s speed tips, all javascript code should be put at the bottom of the documenent (just before the closing body tag). An interactive demo is available here (http://stevesouders.com/hpws/move-scripts.php) comparing the difference between the javascript at the top and bottom of a document. With jquery the loading time difference should be lower than in the demo, but still the javascript's place is at the bottom of the document.
Title: Re: Move the javascript to the bottom of the document
Post by: Joachim Müller on June 10, 2010, 01:00:07 pm
The documentation doesn't have to be optimized for speed, as it meant to be used by the admin of the gallery, preferably using a local copy of the docs. The jquery script will be cashed anyway. As it's not important to speed the docs up in this aspect, they will remain the traditional way, with the JavaScript calls inside between <head> and </head> (sorry, I'm a purist in this aspect).
I guess though that you're not refering to the documentation, but to the output generated by Coppermine. I can see the point here, but then the speed penalty for loading the jquery library in the head is neglible imo. The big performance win in the speed tips is if you move big chunks of inline JS from the head to the end of the document, which is something we hardly do. . As suggested above, I'm not fond to add JS at the bottom inside the body.
Thanks for the suggestion though.
Title: Re: Move the javascript to the bottom of the document
Post by: Αndré on June 10, 2010, 03:18:28 pm
I guess though that you're not refering to the documentation, but to the output generated by Coppermine.
That's what I've understood :)
Title: Re: Move the javascript to the bottom of the document
Post by: Timos-Welt on June 10, 2010, 03:19:24 pm
I just contributed a little plugin to the SVN (http://coppermine.svn.sourceforge.net/viewvc/coppermine/branches/cpg1.5.x/plugins/js_to_bottom.tar.gz?view=tar) to get what papukaija probably wants.

papukaija: Please test the plugin and report if it works for you and if it improves your page access times. On my gallery, it makes the pages usable ~ 3-4 seconds earlier at first time visits.
Title: Re: Move the javascript to the bottom of the document
Post by: papukaija on June 10, 2010, 09:01:33 pm
I guess though that you're not refering to the documentation, but to the output generated by Coppermine.
That's what I've understood :)
Yes, I'm referring to the output generated by Coppermine.

I'll test the plugin tomorrow.
Title: Re: Move the javascript to the bottom of the document
Post by: taucher_0815 on June 11, 2010, 11:55:12 am
works fine for me on http://www.sk-foto.info (http://www.sk-foto.info)
Title: Re: Move the javascript to the bottom of the document
Post by: Timos-Welt on June 11, 2010, 12:39:45 pm
No it doesn't.
http://www.sk-foto.info/thumbnails-lastup.html
produces errors because of the jquery framework coming too late for some inline scripts. I think I'll have to drop the plugin and include the mechanism to my jsmin plugin, leaving the basic scripts always in the head and only moving additional scripts to the bottom of the page. I've done this here (http://pics.timos-welt.de) and everything seems to work fine.
Title: Re: Move the javascript to the bottom of the document
Post by: taucher_0815 on June 11, 2010, 12:45:58 pm
When I try to open the URL you mentioned, i receive a normal output...
Title: Re: Move the javascript to the bottom of the document
Post by: taucher_0815 on June 11, 2010, 12:49:49 pm
Same for Chrome and Safari after clearing all caches
Title: Re: Move the javascript to the bottom of the document
Post by: Timos-Welt on June 11, 2010, 12:52:18 pm
Try IE, or watch the error console of your browsers and you'll see what I mean.
Title: Re: Move the javascript to the bottom of the document
Post by: taucher_0815 on June 11, 2010, 12:59:56 pm
OK, got it...

Plugin is now uninstalled and reporting no more errors.

Thanks for the hint
Title: Re: Move the javascript to the bottom of the document
Post by: papukaija on June 11, 2010, 11:44:14 pm
papukaija: Please test the plugin and report if it works for you and if it improves your page access times. On my gallery, it makes the pages usable ~ 3-4 seconds earlier at first time visits.
With this plugin, the index.php loads 2 -5 seconds faster than without it when the browser's cache is disabled. When the cache is enabled, the difference is about 5 seconds, but only on the first load, after that, the difference is at maximum 0,5 second. I tested this on my local lamp (in FF with Firebug extension). I also noticed that the error console displays many javascript errors.