1

I have Large.html, which is a web page that has a lot of images and javascript on it which takes a long time to load.

From other pages (a.html, b.html) how can I use JavaScript to prefetch Large.html (and all of the elements on the page) so that I can get the page cached in the users browser to help speed up page loading.

Would I need to use a hidden IFRAME?

3 Answers 3

1

You could just load the body of the page, put it into the innerHTML of a div that has 'display: none', and wait for a bit, then make the current div have a display of none and the div with the new page becomes visible.

It may still need to go out and actually download the images, but it should basically be preloaded.

Sign up to request clarification or add additional context in comments.

1 Comment

@mp_ - I tend not to enjoy writing code, as you won't learn from that, but I can give advice. For example, if you use jQuery, then it will take care of the ajax call you need to make. You then need some cgi application (REST service) to connect to, and in your ajax call you will return the body that is needed. jQuery will make your life easier for doing this.
0

yes, i would use a Hidden Iframe. That will, in general, take care of exercising scripts that might run and load in additional assets on that slow-to-load page.

1 Comment

How do I load the large.html IFRAME on a.html after a.html fully loads. I'd hate for a.html to load slowly because it's blocking downloading large.html before a.html finishes rendering
0

If you do this, be sure to do it after the load of the a.html page so that you are not stopping the user interacting on this page.

I say if, because you often don't know for sure that the user will load the Large.html page.

Other than that if the large parts of the other page are mostly images, I would load them, and not the entire page (html, css, js, & images) in an iframe.

I've seen too many sites that try to load the entire content (hidden) in an iframe... and in the process make the current page unusable. :-(

1 Comment

How do I load a hidden IFRAME after a.html loads?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.