Forum Index > glFusion > glFusion Support New Topic Post Reply
 Possible Performance improvement.
 |  Printable Version
By: kingsley (offline) on June 12 2009 11:13 AM (Read 313 times)  
kingsley

In talking with some folks about performance issues with a site they suggested that I move the Java Script calls on the site to the end instead of having them load first in the header. They claimed that this would give an appearance of faster loads although overall load times wouldn't change.

So for kicks on a test site I removed the following from "htmlheader.thtml".

PHP Formatted Code
{# Load JavaScript #}
<script type="text/javascript" src="{js_cache_url}"></script>
{# Load plugin Header Code #}
{plg_headercode}



Now because you can't just paste that into the footer as it won't build I had to paste the full code into "footer.thtml" just before the "</body>".

PHP Formatted Code
<script type="text/javascript" src="http://72.46.237.18/js.php?t=nouveau"></script>
<link rel="microsummary" href="http://72.46.237.18/index.php?display=microsummary" title="Microsummary" />
<!-- Bad Behavior 2.0.26 run time: 12.327 ms -->
<script type="text/javascript">
<!--
function bb2_addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function') {
                window.onload = func;
        } else {
                window.onload = function() {
                        oldonload();
                        func();
                }
        }
}
 
bb2_addLoadEvent(function() {
        for ( i=0; i < document.forms.length; i++ ) {
                if (document.forms[i].method == 'post') {
                        var myElement = document.createElement('input');
                        myElement.setAttribute('type', 'hidden');
                        myElement.name = 'bb2_screener_';
                        myElement.value = '1244821641 75.147.4.85';
                        document.forms[i].appendChild(myElement);
                }
        }
});
// --></script>



Interestingly this did make a subjective difference in page load times. It actually does appear like the pages load somewhat faster. Now things like the hover text over the Forum centerblock don't generate until after the full page loads. Not a significantly long time after but noticeable.

From my perspective I liked the effect of putting the js at the end of the file. The user seems to get their pages faster and can work with the site while the neat little JS stuff loads.

Am I missing something? Is this something to dig into further?

In looking at YSlow it says the following about moving JS to the bottom of your file...

JavaScript scripts block parallel downloads; that is, when a script is downloading, the browser will not start any other downloads. To help the page load faster, move scripts to the bottom of the page if they are deferrable.



So are there any JS that are not deferrable? If not maybe we could think about moving the JS into the Footer?


-Eric


Forum Active Member
Active Member

Group Comfort
Level:
: +7

Status: offline

Registered: 02/12/06
Posts: 280

Profile Email Website PM
  Quote
By: Mark (offline) on June 12 2009 13:51 PM  
Mark

I've always heard it is best to put the JS in the footer if possible. I don't see any reason why we couldn't give it a try. It would take a very minor modification to the header / footer code to make sure the template variables are available in both places. Let me play around with it a bit and see how it works.

Thanks for the info!

Mark

Forum Admin
Admin

Group Comfort
Level:
: +93

Status: offline

Registered: 10/21/05
Posts: 5029
The Great State of
Texas

Profile Email    
  Quote
By: kingsley (offline) on June 12 2009 15:15 PM  
kingsley

Thanks Mark,

I will be interested to hear what you find. So far I haven't had any issues with the site where I move the JS stuff to the bottom.

-Eric


Forum Active Member
Active Member

Group Comfort
Level:
: +7

Status: offline

Registered: 02/12/06
Posts: 280

Profile Email Website PM
  Quote
Content generated in: 0.22 seconds
New Topic Post Reply



 All times are CDT. The time is now 09:24 AM.
Normal Topic Normal Topic
Locked Topic Locked Topic
Sticky Topic Sticky Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Able to Post 
HTML Allowed 
Censored Content