Pradeep
Pradeep

Reputation: 6603

How to reload a webpage without reloading Java Script again?

Purpose : For Google Ads

I need to reload a page without loading js content ( which will be in file) as JS will be bigger in size it will get loaded only for first time and for next page reloads only dynamic content ( like ads , dynamic text) will keep on changing. Is there a way to do this ?

Upvotes: 2

Views: 517

Answers (4)

BigDogGary
BigDogGary

Reputation: 68

Or you can refresh dynamic content using Ajax

http://www.markvoss.net/scripts/ajax.asp

That's an option

Upvotes: 1

Mathias Online
Mathias Online

Reputation: 188

If on Linux you can use the .htaccess file e.g:

See:

http://www.samaxes.com/2008/04/htaccess-gzip-and-cache-your-site-for-faster-loading-and-bandwidth-saving/

This works great.

Mathias

Upvotes: 6

Tom
Tom

Reputation: 1334

Most browsers cache JavaScript and CSS files as long as the name of the file hasn't changed since last time the page was accessed.

Also, if file size is an issue, consider minifying your JS and CSS files. This compresses the files using various techniques while keeping the same functionality. There are various online tools for doing this, my favorite being Online YUI Compressor.

Upvotes: 7

Aaron Digulla
Aaron Digulla

Reputation: 328594

There are two ways:

  1. You can make sure that the JS file can be cached by sending the appropriate HTTP headers to the browser.

  2. If users stay a long time on your site and work with it like a desktop app, you can create an initial page and load the JS once. If you convert all links to send AJAX requests which just replace the content part of the page, the JS won't be loaded again because you never "leave" the page.

Upvotes: 2

Related Questions