PDA

View Full Version : Preloading the next page?



Seannal
03-21-2007, 04:38 AM
Hey guys,

I'm looking to speed up the loading time of my sales letter. What I'm wondering is if there is some sort of script that will allow me to preload the second page of my site while visitors are viewing the first page, so that when they click to access the second page, it's already been loaded.

For example...

Visitor lands on page1.htm (meanwhile, page2.htm is "pre-loading" in the background)

*visitor clicks on link to page2.htm*

Page2.htm loads right away since it was already preloading while the visitor was on page1.htm.


Any ideas??

Thanks a bunch,

Sean

jscheuer1
03-21-2007, 05:24 AM
You could put page 2 on page 1 like so:


<iframe src="page2.htm" width="1" height="1" frameborder="0" scrolling="no" style="position:absolute;top:-3000px;left:-3000px;></iframe>

You should place this tag either right after the opening <body> or right before the closing </body> tag of page 1.

Other strategies you can consider are reducing the byte load of page 2 and/or preloading just its images.

Seannal
03-21-2007, 06:37 AM
Thanks for the reply, I will give this a shot.

Any advice on how to preload the images?

Seannal
03-21-2007, 06:49 AM
I guess I could create a separate page using just all of the images, and use the same iframe strategy?

jscheuer1
03-21-2007, 02:41 PM
You could use a javascript image preloader like so (goes in the head of the page):


<script type="text/javascript">
function preload_page_images(){

//Enter your images (and paths, if any) in the preloads array:
var preloads=['image_1.jpg', 'image_2.jpg'];

/////////// Stop Editing ////////////

var loadem=function(im){
var pimg=new Image();
pimg.src=im;
}
for (var i_tem = 0; i_tem < preloads.length; i_tem++)
loadem(preloads[i_tem]);
}
preload_page_images();
</script>

If you are doing this, as you propose, on a previous page, use:


onload=preload_page_images;

in place of the red highlighted line. Preloading on the page itself will not save any time and is only good for preloading small rollover images.

You could also do as you propose with the iframe. This would have the advantage of working even for folks who have javascript disabled.

One thing that will help with or without preloading is optimizing your images. This is something that generally should be done for any page with significant image byte load.

And, don't be fooled into thinking that preloading the page (I like the idea of preloading the whole page) or images will speed things up beyond the available bandwidth. By this I mean - say, it takes 5 minutes for a dial up user to load the images for your page. If you preload them on another page, this will save the full loading time for the user only if they stay on the preload page for its loading time plus the 5 extra preload minutes. This is why it is also important to reduce the overall image byte load.

Sparaker
03-21-2007, 03:46 PM
You could use the technique suggested by jscheuer1 or i could help you write the ajax code which could do that. ;)

Just let me know if you'd need help from me.

jscheuer1
03-21-2007, 05:39 PM
You could use the technique suggested by jscheuer1 or i could help you write the ajax code which could do that. ;)

Just let me know if you'd need help from me.

It seems to me that Ajax is overkill for preloading. Some browsers still do not support it, it cannot possibly speed up the process and, in fact may well slow it down.

Sparaker
03-21-2007, 05:45 PM
It seems to me that Ajax is overkill for preloading. Some browsers still do not support it, it cannot possibly speed up the process and, in fact may well slow it down.

The advantage of ajax is that when you will click the link to the next page the javascript can instantly place the next page's content in place of the current page. And to my knowledge Ajax is supported in almost all the browsers except for the really really old versions.

Twey
03-21-2007, 05:56 PM
The advantage of ajax is that when you will click the link to the next page the javascript can instantly place the next page's content in place of the current page.... nicely breaking navigational features such as history, bookmarks, and even the "back," "forward," and "up" buttons.
And to my knowledge Ajax is supported in almost all the browsers except for the really really old versions.And all those with Javascript disabled.

Sparaker
03-21-2007, 06:06 PM
... nicely breaking navigational features such as history, bookmarks, and even the "back," "forward," and "up" buttons.And all those with Javascript disabled.

disabling javascript is a users own choice. it doesn't mean that the browser doesn't support ajax. ;)

Jas
03-21-2007, 07:32 PM
Is this a debate?

There are lots of ways, as established.

mburt
03-21-2007, 08:24 PM
disabling javascript is a users own choice. it doesn't mean that the browser doesn't support ajax.
AJAX is a part of JavaScript. Disabling JavaScript will have the same effect for AJAX - nothing.

jscheuer1
03-21-2007, 10:10 PM
Getting back the the original question of this thread, preloading - Using Ajax as currently proposed to load the page instead of using a normal link would do nothing to preload its content and would in fact often slow the process down.