Let's say my website has 5 pages of content. Is it possible to preload the next two pages while visitor is viewing the first page. So that when they click the link to 2nd or 3rd page, it will appear immediately.
Sure, you can have some invisble containers like this:
HTML
<div id="page">
<a href="page2.html" id="page2-link">Go second page</a>
</div>
<div id="page2">
</div>
CSS
#page2 { display:none }
Javascript
Then when at the javascript preload the second page after it has been loaded and put it on the invisble container:
$().ready(function(){
$('#page2').load('page2.html #page');
});
And when the link is clicked just show the hidden container with selected page and remove the other, or just hide it to not load again when user wants to return or something.
$().ready(function(){
$('#page2-link').on('click',function(){
$('#page').html( $('#page').html() ); //this will replace html content
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With