Gauges affect on page loadspeed

Hi,

First, the Steelseries gauges are damn great thing and i’m itself implenting them on my page. :smiley:

But few things have came up during playing with them:

IE9: Alltought IE9 supports canvas, it fails miserably on the gauges and takes ages to load, meaning that IE9 should also be shipped to “old page”. See measurements later in the post.

Page load-speed: From my measurements of my frontpage on nordicweather Steelgauges slows down the load of the page (time taken for browser from to ) with at least 3 seconds, this with Chrome/SWare Iron, FF/IE9 are even slower. As pointer i have readed that if (front)page takes more than 2 seconds (2000 ms) to load site will start loosing visitors. This means theese can’t be used on frontpage but on an own gauge-page. As example, i readed that Google’s traffic decreased with 20% when loadspeed increased with only 500 ms.
Not to forgot Google’s listings, if it thinks our frontpages are too slow it will drop our rankings. Do we want that? No!

Speed-measurements - :

gauges-ssT-page, only the gauges
Chrome/SWare Iron: 2700 ms
FF11/PaleMoon: 3500 ms
IE9: 14000 ms

nordicweather.net frontpage, with Chrome
Old frontpage: 2700 ms
New frontpage with Steelgauges: 6000 ms

Further reading:
http://stackoverflow.com/questions/3108495/what-is-an-appropriate-page-processing-time-for-a-web-application
http://www.svennerberg.com/2008/12/page-load-times-vs-conversion-rates/

henkka

Maybe you could add your page URL’s? By “gauges-ssT-page, only the gauges” do you mean http://www.nordicweather.net/mittarit.php?en ? Is that page redirecting IE9? I ask because it works fine for me in IE9, and loads in about 2 seconds, even on my slow connection and not terribly fast PC :?

I’m not sure how much faster you can expect something as complex and good looking to load…

By "gauges-ssT-page, only the gauges" do you mean http://www.nordicweather.net/mittarit.php?en ?
No, i meaned the testpage shipped with the zip, http://www.nordicweather.net/gauges-ss_v1-6-5/gauges-ssT.php.

Look for the Loadtime at bottom of the page, i get around 3600ms in FF11 with multiple trys.
That page takes by far over 10 seconds to show up here in IE9 (W7, dual-core CPU) and get 14-17000 ms as results.
Thats the time it takes before page are ready.

And no, there are nothing bad with my connection, i get ca 10 Mbit down from that server with my ca 10 Mbit connection :slight_smile:

http://www.nordicweather.net/mittarit.php?en have only the gauges, not whole frontpage what i measured with before moved them to own page :wink:

Btw, modded set of gauges in use here: http://www.nordicweather.net/status.php?en :slight_smile:

henkka

Thanks for the clarification. For http://www.nordicweather.net/gauges-ss_v1-6-5/gauges-ssT.php I get Loadtime: 2232ms in IE9, W7/32, 2.4 GHz core2duo laptop, on a 1.5 megabit connection, so I’m still confused by your IE9 comment.

I’m not confused at all. :slight_smile: It just shows that it even if it works for the developer it may not work for all the visitors “with same specs”.
Also many may use Atoms with less horsepower w/o external graphic-card what needs be taken in account.
As compare, what do you get on my frontpage http://www.nordicweather.net now? (Look at bottom of the page)

Add then those 2200ms it took for the gauges and you see what it should take to load if use gauges on frontpage, at least here the slowing they cause are pretty same no matter are they standalone or not (in all browsers).

Henkka

Loadtime-check: 8861ms

Well I am, I don’t understand why your comparable PC with your fast connection is taking 5 times as long to load the page. You made the generalization that IE9 “fails miserably” but I’m not seeing that :?

Loadtime-check: 8861ms
I get around 3-4000ms in both FF and IE9 on frontpage. Ubuntu webfont and jQuery UI do some hundred ms'es each there.
Well I am, I don't understand why your comparable PC with your fast connection is taking 5 times as long to load the page. You made the generalization that IE9 "fails miserably" but I'm not seeing that
That true its a bit strange that you get it that fast and here its slow, but all i asked here to test it said its slow in IE9, while current frontpage are fast.

No comment on the relative speed of the browers, but you can probably decrease the page load time quite a bit by concatenating all the separate JS files into a single file and loading that. The sample page I supply is really meant to be just a demo page, it is not fully optimised so it is clear(ish :slight_smile: ) to users how it all hangs together.

For you production page at the very least you would normally minimise all your scripts and combine them into the minimum number of separate downloadable files. If you do concatenate, maintain the same order as the individual scripts in the sample page.

For you production page at the very least you would normally minimise all your scripts and combine them into the minimum number of separate downloadable files. If you do concatenate, maintain the same order as the individual scripts in the sample page.

For sure i have done that.
For example my minimized and gzipped steelseries.js are 30.5 KB vs the unminimized and unzipped 690 KB (tween & RGraph included) together with “If modified” http-header so it is downloaded actually only once until its modified.
But there are also a problem in the gauges’ script, language.js can’t be minimized due to UTF8 and

Hi all

Here are my test-results for:

Old gauges frontpage (www.silkeborg-vejret.dk/index.php)

New gauges frontpage (www.silkeborg-vejret.dk/index3.php)

Testcomputer: Acer Aspire 7535G Laptop (AMT Athlon 64x2 2,1Ghz/4GB RAM/ATI up to 1471MB)
Testconnection: Broadband 20/2 Mbit/s

  • Note: First test in each browser is with cleared cache

** Note2: Test with IE8 is made by Acer Revo 3610: (Intel Atom 1,6Ghz/4GB RAM)

*** Note3: Test with IE7 is made by Lenovo Thinkpad T420s (Intel i5-2520M 2,5Ghz/3,41GB RAM)

[b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b] [b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b] [b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b] [b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b]
[b][color=red]IE9[/color][/b] 3719 ms * 7460 ms * [b][color=red]Chrome (vers. 18)[/color][/b] 5430 ms * 6422 ms * [b][color=red]Safari (vers. 5.1.5)[/color][/b] 2736 ms * 4670 ms * [b][color=red]Firefox (vers. 11)[/color][/b] 3395 ms * 6449 ms *
2541 ms 5431 ms 1717 ms 3910 ms 2572 ms 4216 ms 2628 4643 ms
899 ms 19644 ms 1619 ms 2728 ms 3251 ms 4269 ms 2785 4431 ms
1963 ms 26417 ms 1757 ms 2864 ms 2420 ms 4012 ms 2810 4583 ms
[b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b] [b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b] [b]Browser[/b] [b]Old gauges[/b] [b]New gauges[/b]
[b][color=red]SRWare Iron (vers. 17)[/color][/b] 2200 ms 3234 ms [b][color=red]IE8 **[/color][/b] 2751 ms * N/A [b][color=red]IE7 ***[/color][/b] 6078 ms * N/A
1825 ms 3128 ms 2765 ms N/A 4049 ms N/A
1516 ms 3438 ms 2481 ms N/A 1798 ms N/A
1410 ms 2686 ms 2385 ms N/A 1990 ms N/A

As you can see IE is significant slower than the other browsers. Also its pretty clear that the new gauges are slower in all browsers.

Right now my plan are to keep the new gauges (because the look sooooo fancy) as my frontpage for all browsers except IE. IE users will automatic be redirected to the old gauges frontpage.

Best regards,

Henrik

Ps. A friend of mine has done the same test as above and his results are nearly the same as my test.

[quote author=weatherc link=topic=55391.msg444981#msg444981 date=1333907498]
But there are also a problem in the gauges’ script, language.js can’t be minimized due to UTF8 and

A minimizer will have very little effect on that script anyway as the bulk of the file size is text strings, all it can really do is remove white-space. The only for this file is to statically compress it - and remove any languages you do not need.
Thats true. Minimizing will not do much difference there. Having now langauge.js, tween.js steelseries.js and gauges.js at size of 36 KB gzipped (tween & steelseries are minimized) :) Gzipping is what do almost difference there, unzipped they are 155 KB.

Got also with some tweaks to how the gauges are rendered time for drawing 10 gauges down to pretty wobbling 1500 ms in SWare Iron/Chrome on my testpage: http://www.nordicweather.net/mittarit.php?en :smiley:

Henkka

Hi Henkka, would you be willing to share your optimisations?

Mark,

Sure. :slight_smile:

First, I use jQuery’s built-in ajax. As jQuery are needed for the tooltips, why not use it. I has many error-handlers if they are wanted to be used. As example, IsActive-function could be ajax-function name:

    error:function(jqXHR, exception) {
            setLed(false, exception);
            httpError+=1;
            if (jqXHR.status === 0) {
                setStatus('Not connect. Verify Network.');
            } else if (jqXHR.status == 404) {
                setStatus('Data not found. [404]');
            } else if (jqXHR.status == 500) {
                setStatus('Internal Server Error [500].');
            } else if (exception === 'timeout') {
                setStatus('Time out. Retrying...');
                if(httpError<3){setTimeout('IsActive()', 2000);}
                if(httpError>=3){setStatus('Gived up.');}
            } else if (exception === 'abort') {
                setStatus('Data request aborted.Retrying...');
                if(httpError<3){setTimeout('IsActive()', 2000);}
                if(httpError>=3){setStatus('Gived up.');}
            } else {
                setStatus('Uncaught Error.'+jqXHR.responseText);
            }
    }

From my measurements are windrose pretty heavy and slows down the page getting ready more than other gauges. If want faster pageload it should it not be used or it should be drawn later in some way and at least not in same function as the rest gauges are drawn. Windrose are also pretty useless to have ajaxed as its data will not change much anyway in the time average user looks at it, just drawing it once are enough. Expecially if slower CPU/GPU drawing the gauges stall the browser at least for some time, thats the silly fact. That stalling can disturb visitors and also getting them elsewhere for sure. On my testpage are windrose not used.

Learned also during fiddling with theese that javascript are one-threaded, this means it can do only one thing at time (sigh).
One important thing are also in wich order js-files are loaded and then runned.

  1. One CPU-huge thing was the “canvas-detection” in orginal script. Replacing it with modernizr.js what detects many other things too like box-shadows dropped CPU-usage drastically. Instead of trying creating an unvisible canvas only this are needed:

if(!Modernizr.canvas){
// what do if no canvas
}

  1. I have the gauge-ajax integrated to topbanner ajax (called scripts.js) and biggest improvent was when i lifted out the gauge-ajax from gauges.js and integrated it to topbanner-ajax. This script are loaded and then ajax fired before any steelseries-scripts are loaded. Then we have clientrawdata available soon as steelseries are ready and not need to wait for the ajax. In orginal are ajax fired first when all steelseries-scripts are loaded. Thats an unneeded slowdown as steelseries-scripts takes some time to be loaded, are they shipped from browser-cache or not.
    Instead, in topbanner-ajax are an if-function what runs the update of gauges if steelseries are defined (about line 88 in scripts.js):
if(typeof steelgauges == 'function') {
steelgauges(ns);
}

steelgauges() are updatefunction for gauges, ns are clientrawdata-array.

  1. Have also integrated drawXxxx() with doXxxx() a bit. Gauges are both drawn and updated with same command doXXX(). It just check if gauge in question are defined, if not it calls drawXxxx(). And here is what seems to be the magic, i used setTimeout’s when call drawXxxx(), as example:
if(gauge_temp === undefined){
        setTimeout(function(){
        drawTemp();
        $('#canvas_temp').qtip({content: g_temp.tip});
        setTimeout(function(){
        doTemp();
        ;
        },2);
        },2);
        }

Note, i use qTip2 as tooltip-plugin here.
Working files:
http://scripts.nordicweather.net/jquery/scripts.js
http://scripts.nordicweather.net/jquery/gauges.js

For usage on page where gauges are not at top of the content and therefore not visible for visitor at initial load, when ex. having a forecast at top, i suggest usage of a lazyloader (ex. Modernizr.js) to load steelseries.js async, like this:

  Modernizr.load({
           load: ["http://scripts.nordicweather.net/jquery/language.js",
                  "http://scripts.nordicweather.net/jquery/steelseries.min3.js",
                  "http://scripts.nordicweather.net/jquery/gauges.js"],
                  complete: function(){steelgauges(ns);}
  });

In use as test here: http://www.nordicweather.net/index.php with other bowser than IE, you see that topbanner-ajax shows up almost immedately here and steelseries do not stall the load of the page.

EDIT: Changed the last url to reflect the changes on the site, steelgauges are now on frontpage for other browsers than IE.

Henkka

Thanks for the comprehensive reply Henkka, I’ll take a while to go through this and understand it fully…

…and wait for version 2 of the gauges page where I will incorporate some of Henkka’s ideas, some adaptations of his code, and some other optimisations that I had planned, into the sample page - it’s going to take a while to find the time though…