Closed (fixed)
Project:
Javascript Aggregator
Version:
5.x-1.3
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
20 Apr 2008 at 11:28 UTC
Updated:
12 Nov 2008 at 21:23 UTC
Hi,
I've opened my theme's page.tpl and found the script
<?php print $scripts ?>
which is in the Header
And I placed your code as per instructions in the README.txt. So no it looks like this
<?php
if(module_exists('javascript_aggregator')) {
$scripts = javascript_aggregator_cache($scripts);
}
?>
<?php print $scripts ?>
...However, this articlehttp://wimleers.com/article/improving-drupals-page-loading-performance (see Rule 6) claims that the Javascript
<?php print $scripts ?>
should be placed at the bottom of page.tpl... and so I have to ask:
What should we do? Should we put that code in the header by default??? Or at the bottom as per that article's instructions???
The strange thing is that either way my YSlow Firefox plugin shows an "A" for "Put JS at the bottom"
Comments
Comment #1
derjochenmeyer commentedmaybe some js is put in the bottom and so it gives you and A (maybe google analytics)? But however, im no "performance neurotic" ;-) i got a huge performance boost from the js aggregation for drupal 5... other from that i try to use as little js as possible, keep the css files small, compress images ... (http://en.wikipedia.org/wiki/Pareto_distribution) .... ;-)
i think you could mess things up by putting the $scripts near the footer... ? but i havent thought it through... any feedback is very welcome...
Comment #2
drupalina commentedhmm...
no, I'm not using GoogleAnalytics (not yet). Didn't know that it's using JS...
There's a posting and discussion by Greg Kanadisson in one of groups.drupal.org about putting JS in the footer. There's also a lot of discussions on putting JS at the bottom, especially in relation to Drupal. With drupal these things are not as straight-forward as will ordinary sites.
You compress images? How???
I thought images were already compressed files. I read somewhere that if you try to gzip images that could actually slow down your pageloads.
Comment #3
derjochenmeyer commentedsorry ;-) what i meant is this: i cant answer the question where the best place for js files is. There are very many cases to consider (it could possibly break a lot of things). This is somehting that i will not solve or adress with this module...
you were asking why yslow gives you an A ... i think it just detects that some scripts were found at the bottom and so it assumes you already optimzed this aspect...
i compress my images using photoshop ;-) sorry for that confusion ...
Comment #4
antipix commentedIt's better to put your js files in the bottom but it could cause some problems...
Some library (jquery or other) need to be called in the header in order to use them in the page. I tried to put the echo $scripts before and Fck Editor stopped to work.
I think you could prevent some files to be aggregated in the performance interface but i don't know if it will give you an extra speed loading.
For me, most important thing is to put the external javascript files in the bottom (like googleanalytics scripts) because they block page rendering...
Having my aggregated and minified javascript file in the header, and the google stat scripts in the bottom allways give me an A grade in yslow for "Put the JS at the bottom"
Comment #5
owen barton commentedAlmost every JS should work at the bottom of the page (including jquery and it's plugins) and placing them at the bottom of the page gives a huge boost to page rendering performance, because otherwise the browser can't begin building the page until all the JS code has downloaded. At the bottom of the page (just before ) the page can be all ready for action when the JS arrives.
Comment #6
robloachYahoo recommends sticking the scripts at the bottom of the http://developer.yahoo.net/blog/archives/2007/07/high_performanc_5.html page. Many themes, like Blueprint do this for you.
Comment #7
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.