Forum Moderators: open

Message Too Old, No Replies

Delay javascript loading

delay javascript loading

         

steve28

6:06 am on Oct 10, 2005 (gmt 0)

10+ Year Member



Hi,

I've got about 5 javascripts that load on my main page, but I have identified one that seems to be slowing up the overall loading time of the page. What I would like to do is to be able to specify one or a couple of javascripts to delay their loading so that it speeds up the loading time of the page. Bear in mind that I have no experience writing or altering javascripts!

If someone could give me an exact example of how I could go about doing this, that would be much appreciated!

Thank you for your time.

Bernard Marx

6:56 am on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is an attribute, defer.

<script src="blah.js" type="text/javascript" defer="defer">

This suggests that the client may wait till the rest of the doc is downloaded before downloading the script. It may be simpler to put your offendingly heavy scripts at th bottom of the page.

seems to be slowing up the overall loading time of the page.

What may be happening is that the script is initialising the elements within the page. There may belittle that can be done about this. We'll need to know what the script does(and why it's so large).

steve28

7:16 am on Oct 10, 2005 (gmt 0)

10+ Year Member



Thanks for the reply.

I have 3 Google ads, a phpbb topics anywhere js, and an Absolute News Manager js that displays a set number of headlines. It is this last one that seems to cause the problem. I tried using the defer attribute before posting to this forum, however it loaded up the js in the whole window after loading up my main page, so I don't know what that's all about.

Bernard Marx

9:24 am on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nor do I. Perhaps your news manager script uses document.write, in which case it is overwriting the document. It also means that you can't take any steps to defer it. You probably just have to live with it.

encyclo

5:27 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is there any way of having the news manager script placed within a separate HTML document inside an
iframe
? That might help you in that your main page will load independently of the framed page section.

steve28

6:23 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



I tried that. The only problem is that the article then opens within the iframe itself, not in a new window.