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?
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?
No. (body must be at least 15 characters; you entered 3)
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:
Why not? It may be cached along with the entire html file, but then of course any dynamic content must be done with ajax ;-)
The tag itself, no. This is one of the nice benefits of external JS files, in addition to separation of concerns. It is not normal to cache individual tags in a document, though, and I'm not sure what the benefit could conceivably be. Either the whole HTML document is cached or none is — never just the <script>
s or the <p>
s or whatever.