homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

How to load JS code for future pages in advance?

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


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?




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

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)

Thanks.... That works



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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved