Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to cache JS inside <script/> tags on HTML page?

When JavaScript is inside external .js file it's cached on the browser.

Is it possible to do the same with JS inside tags on HTML page?

like image 972
cinek Avatar asked Jul 06 '10 11:07

cinek


1 Answers

No.

Alright a little insight of what you're asking for.

Imagine the script tag's content is cached. What would be the name of it? How the browser would identify? Alright somehow it manages to do that. But then comes the real question:

What would you benefit from that? You have no access to the browser's cache so you need to send the same inline script tag with every request as it can be in the cache or not.

To sum up, it is:

  1. impossible
  2. useless
like image 108
25 revs, 4 users 83% Avatar answered Sep 29 '22 21:09

25 revs, 4 users 83%