Welcome to WebmasterWorld Guest from 23.22.79.235

Forum Moderators: open

Message Too Old, No Replies

How to load JS code for future pages in advance?

   
7:32 pm on Aug 19, 2009 (gmt 0)

5+ Year Member



Hi,

I have three web pages that use javascript.

page 1 - Very light in size with a basic form. Very little form validation and cookie setting JS code here.
page 2 - Very high amount of JS code depending on cookies set and form fields on previous page. There can be a lot of user interaction.
page 3 - Very high amount of JS code used to work with HTML and CSS.

Now, since page-1 is very light in size, I want to download some of the JS code used on page-2, when user lands on page-1. I want to put it in browser cache and use it when user reaches page-2.
Page-2 has a lot of interaction, and user is expected to be on this page for some time. I want to use this idle internet connection time to download the JS code for page-3.

Is this possible to do?

Thanks
Su

7:47 pm on Aug 19, 2009 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



You can't do this with inline scripts, but you can do it if each one is it's own external javascript file.

Just include the external scripts and make sure those files send the right caching headers. :)

8:01 pm on Aug 20, 2009 (gmt 0)

5+ Year Member



Thanks.... That works

Su

7:07 pm on Aug 22, 2009 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



No problem Su, glad it worked out for you. :)