Do browsers parse javascript on every page load?

Viewed 30234

Do browsers (IE and Firefox) parse linked javascript files every time the page refreshes?

They can cache the files, so I'm guessing they won't try to download them each time, but as each page is essentially separate, I expect them to tear down any old code and re-parse it.

This is inefficient, although perfectly understandable, but I wonder if modern browsers are clever enough to avoid the parsing step within sites. I'm thinking of cases where a site uses a javascript library, like ExtJS or jQuery, etc.

6 Answers

I think that the correct answer would be "not always." From what I understand, both the browser and the server play a role in determining what gets cached. If you really need files to be reloaded every time, then I think you should be able to configure that from within Apache (for example). Of course, I suppose that the user's browser could be configured to ignore that setting, but that's probably unlikely.

So I would imagine that in most practical cases, the javascript files themselves are cached, but are dynamically re-interpreted each time the page loads.

Related