Welcome to WebmasterWorld Guest from

Forum Moderators: DixonJones & mademetop

Message Too Old, No Replies

JavaScript Logging

Can you explain my puzzling results?



12:41 pm on Sep 7, 2002 (gmt 0)

10+ Year Member

Hi, I use a home-grown logging system which uses JavaScript & Perl to log sundry visit data.

Following recommendations here, I was concerned that my E-Commerce website pages may be too large. They average 100K in size, which maps to 22 secondws download on a 56K domen.

So I added logging elements to detect when pages were abandoned before being completely loaded.

I did this through Javascript with:

<BODY onLoad="record('Loaded');"...

- which works well. I can detect the fact that the page completed loading through the log entry, and I can measure the time the page took to load by comparing the log entry time with its immeditate predecessor (which logged the page being accessed).

Two things:

1. My logs seem to show that 94% of people completely load the pages, suggesting that page size is NOT a factor in my website conversion ratio.


2. The average page load time is 14.5 seconds, which implies an average link speed exceeding 56Kbps.

Any comments on this? Specifically - will onLoad do what I am expecting here reliably? Any other explanations on the apparent speed implausibility?


Mikkel Svendsen

1:34 am on Sep 8, 2002 (gmt 0)

10+ Year Member

I would like to know more about how you can be 100% sure you log when the page has been loaded? :)


2:10 am on Sep 8, 2002 (gmt 0)

10+ Year Member

I think the most basic problem you'll face is people like me who browse with JavaScript turned off.


10:18 pm on Sep 8, 2002 (gmt 0)

10+ Year Member

I can't add to my earlier explanation of how "page loaded" is measured, I juss call the Java Script function provided.

Sure, with JavaScript off, none of this works, but I don't really care, as the goal here is to judge whether or not page size is turning customers away. The fact that up to 10% of logs are missing due to disabled JS is not a factor in this analysis.


Mikkel Svendsen

11:03 pm on Sep 8, 2002 (gmt 0)

10+ Year Member

The reason I am asking is that as far as I know it is not possible to measure when a page has finally loaded unless you check the data packages. However, I could be wrong, so I'd just like to know how you do it (or the ones who supplied the script)

I can imagine one way that they "think" they can do it - and that would be by placing some code in the end of the HTML that calls the function. However, I do not believe there is any way to controll what objects are being loaded first or last so the script don't have to be loaded last just because it's last in the code.

The reason I am digging into this is that your numbers do not sound right to me. I very much doubt your average user can download with that speed.

Denmark (and Scandinavia) is one of the places with the highest broadband penetration and we don't get anywhere close to that (measure on network level).

Also, even if most users will download your entire pages do not expect spiders to do so. 100 k is lot - if you multiply that by 2.5 billion pages... and growing! You should not expect spiders to eat all that :)


9:14 am on Sep 9, 2002 (gmt 0)

10+ Year Member

Hi Mikkel,

I added a JavaScript OnLoad event inside the BODY tag. This event is native to JavaScript - it is not an add-on script. There is no other information to add. The implementation of this language primitive is down to the browser manufacturers. From the browser programming environment, it will be easy to know when all GET requests have been fulfilled, so I would think this primitive works reliably, but then - part of the reason for my post was to check this.


Mikkel Svendsen

7:29 pm on Sep 9, 2002 (gmt 0)

10+ Year Member

With the limited documentation available it is hard to say if it works or not - but I doubt it :)


10:02 am on Sep 11, 2002 (gmt 0)

10+ Year Member

Eh? Why wouldn't a build-in JavaScript language primitive work?

Mikkel Svendsen

12:25 pm on Sep 11, 2002 (gmt 0)

10+ Year Member

Because there is no way for the JavaScript to know when the page has loaded :)

I have so far only seen two ways to determine that - and one one that is bullet proof.

You can compare the downloaded file sizes with the actual file sizes. If the file returned from the server is smaller than the actual file you know they didn't get all of it - but you don't know why (don't the session terminate? Did they hit http stop request? Or did something else happen...?)

Using Network Package Sniffing you can grab the stop request and also analyse the raw data packages to compare what is requested and what is returned - not what the server return, but what is actually transmitted as data to the client.

I believe the last solution is the best (but also very pricey!)


8:40 am on Sep 12, 2002 (gmt 0)

10+ Year Member

check [htmlcompendium.org,...] they have a good section of this with examples you can try in different browsers... But I would go with comparing file sizes as (a) it reduces the amount of code to be maintained on a page and (b) doesn't rely on the user


9:50 am on Sep 12, 2002 (gmt 0)

10+ Year Member

I would have thought the browser will know when the page is completely loaded, as it is issuing HTTP GET requests for all page elements, and will be able to read EOT from the pipes in all cases.

When there are no more open GET requests, the page is fully loaded.

Since the browser knows this, it can inform the onLoad JavaScript primitive of the correct answer in all cases.



10:10 am on Sep 12, 2002 (gmt 0)

10+ Year Member

Yes, onLoad should fire when the page is completely loaded, including graphics etc.
Whether all browsers have this correctly implemented I'm not sure, I read somewhere that it might sometimes be buggy (no details given though, it was actually in a rant on a blog about why Mozilla is better than IE, so of questionable credibility).
Your logs might also be skewed a bit by people with graphics turned off (although I don't believe those could be more than 1%), plugins not installed, etc.
Also, the average speed alone might not be enough detail. Maybe a few people on very fast provider/office lines are skewing that.


10:38 am on Sep 12, 2002 (gmt 0)

10+ Year Member

Good points all, c3oc3o, thanks.



Featured Threads

Hot Threads This Week

Hot Threads This Month