Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Move the javascript to the bottom of the document  (Read 9814 times)

0 Members and 1 Guest are viewing this topic.

papukaija

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 333
Move the javascript to the bottom of the document
« on: June 10, 2010, 09:37:48 am »

According to Google's and Yahoo!'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 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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: Move the javascript to the bottom of the document
« Reply #1 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.
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Move the javascript to the bottom of the document
« Reply #2 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 :)
Logged

Timos-Welt

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 808
    • Timos-Welt
Re: Move the javascript to the bottom of the document
« Reply #3 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.
Logged

papukaija

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 333
Re: Move the javascript to the bottom of the document
« Reply #4 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.
Logged

taucher_0815

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 134
Re: Move the javascript to the bottom of the document
« Reply #5 on: June 11, 2010, 11:55:12 am »

works fine for me on http://www.sk-foto.info
Logged

Timos-Welt

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 808
    • Timos-Welt
Re: Move the javascript to the bottom of the document
« Reply #6 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 and everything seems to work fine.
Logged

taucher_0815

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 134
Re: Move the javascript to the bottom of the document
« Reply #7 on: June 11, 2010, 12:45:58 pm »

When I try to open the URL you mentioned, i receive a normal output...
Logged

taucher_0815

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 134
Re: Move the javascript to the bottom of the document
« Reply #8 on: June 11, 2010, 12:49:49 pm »

Same for Chrome and Safari after clearing all caches
Logged

Timos-Welt

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 808
    • Timos-Welt
Re: Move the javascript to the bottom of the document
« Reply #9 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.
Logged

taucher_0815

  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 134
Re: Move the javascript to the bottom of the document
« Reply #10 on: June 11, 2010, 12:59:56 pm »

OK, got it...

Plugin is now uninstalled and reporting no more errors.

Thanks for the hint
Logged

papukaija

  • Contributor
  • Coppermine frequent poster
  • ***
  • Country: 00
  • Offline Offline
  • Posts: 333
Re: Move the javascript to the bottom of the document
« Reply #11 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.
Logged
Pages: [1]   Go Up
 

Page created in 0.024 seconds with 19 queries.