JS script works 80% of time

I have a site that uses a sort of coverflow to display images. The coverflow is a JS implementation.

A fair amount of time, the script works fine. Other times, it does not. The page loads but the script does not start. Reloading the page usually gets the script to work.

I think that the script may be trying to start before the page has finished loading.

Is there a way to delay running the script until I’m sure the page has loaded? That at least would confirm this hypothesis (or not).

The site is http://beatricehanblett.com/bodies

Thanks in advance…

Of course you have to spell it exactly, otherwise it’s a link to somewhere else!

The problem is not with delaying it, as it’s wrapped in a window.onload(), which delays execution until everything has loaded, including all the loads of stylesheets! You have over 30 different CSS files being loaded! This means 30 separate HTTP requests. And each one seems to contain only 1 rule. What’s the point of that?

Once you sort this problem out (combine them into 1 file) then perhaps you’ll see the HTTP request for the javascript fail less than 20% of the time (I can’t replicate this, it works every time for me). You should also consider combining all the JS into a single file.

I strongly recommend you look at the advice here.

oh, I didn’t realize I had to spell it exactly … oops

http://beatricehamblett.com/bodies

… and thanks for replying/looking…

ps… Then select any of the four images…

The link seems to be broken.

That was a weak attempt at a joke…

The problem is not with delaying it, as it’s wrapped in a window.onload(), which delays execution until everything has loaded, including all the loads of stylesheets! You have over 30 different CSS files being loaded! This means 30 separate HTTP requests. And each one seems to contain only 1 rule. What’s the point of that?

The point of that is that I use a program called Rapidweaver to create my themes and menues. Their code splits CSS files as you have seen. This is a known issue, and the next release of RW will address that. I could combine the css but as this release is expected shortly, I think I prefer to wait.

Their are two basic javascripts. One (the contentflow), I have some control over. The other - “highslide.js”, I do not.

I was hoping it would be something simple, but as you note, a) the symptom doesn’t happen often b) I would lose out on updates from both the RW community and the highslide community if I go my own way.

I’m not averse to doing so, but I think I should bide my time.

Thanks for looking at this.