tags on an HTML page? When JavaScript is inside an external .js file, it is cached in the browse...">

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

When JavaScript is inside an external .js file, it is cached in the browser.

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

+3
source share
3 answers

No.

Well understanding what you are asking for.

Imagine the contents of a script tag being cached. What will be its name? How will the browser be identified? Well, somehow it succeeds. But then the real question arises:

What would you benefit from this? You do not have access to the browser cache, so you need to send the same inline script tag with each request, as it can be in the cache or not.

To summarize, these are:

  • impossible
  • useless
+7

? html , , , ajax; -)

0

The tag itself, no. This is one of the nice advantages of external JS files, in addition to sharing problems. However, it is not entirely normal to cache individual tags in a document, and I'm not sure if this may be possible. Either the entire HTML document is cached, or not - never just <script>, or <p>or something else.

0
source

Source: https://habr.com/ru/post/1753287/


All Articles