Andy Hin
Andy Hin

Reputation: 31973

How to preload and cache URLs/links using JavaScript?

I have a signup page that has links to 3 different pages. I want to preload all 3 of those destination pages while the user is still on the signup page. This way, the user does click it, it will load immediately.

Is it possible to do this using AJAX or an iframe and have the contents of the URL cached to by the browser?

Upvotes: 1

Views: 317

Answers (2)

Jinto
Jinto

Reputation: 865

Now chrome supports dns prefetching. But it is pretty new and not all browsers supporting it.

You can load all the resources(scripts, styles, images) in the upcoming pages in your signup page dynamically. In this way browsers will cache the resources. And, if you are using partial templates, you can preload that also.

Upvotes: 1

Jonas Grumann
Jonas Grumann

Reputation: 10786

This can be achieved with ajax.

On page load start loading the three pages, as soon as you receive each html file place them in three different hidden divs, when the user clicks a link hide the correct div. Remember to check what happens if the user clicks a link before you get your html back

Upvotes: 0

Related Questions