Connection failed. Please try again.

Skip to content
SEO Tools
Help and documentation
Speed Low impact Medium 30–60 min

Inline scripts

Many <script>s directly in the HTML block and can't be cached.

What it is

Inline scripts are code directly in <script>…</script> in the HTML (not an external file). They block rendering at the point of occurrence and can't be cached or deferred via defer/async.

Why it matters

Large inline scripts inflate the HTML and block rendering. They also complicate the security policy (CSP).

How to do it

  1. 1Move the code into external .js files and load them with defer.
  2. 2Keep small essential initializations, but keep them minimal.
  3. 3Consider CSP — inline scripts complicate it.

Conclusion

External files with defer usually beat inline scripts (cacheability + non-blocking). Move large inline blocks out; small initializations are fine. This is related to the overall strategy of deferring JS.

Related topics