# Inline JS

> Inline JavaScript is code written directly in the HTML inside `<script>` tags, instead of in a separate file the browser can cache.

- **Check ID:** P5
- **Area:** [Performance](https://be1st.ai/glossary/performance)
- **Tool:** [SEO + Security + Performance](https://be1st.ai/tools/ssp-audit)
- **Page:** https://be1st.ai/glossary/performance/inline-js

## Why it matters

Inline JavaScript blocks the HTML parser and cannot be cached by the browser. Large inline scripts slow down Time to Interactive and increase the size of every HTML document. External scripts can be cached, minified, and loaded asynchronously using the async or defer attributes.

## In practice

Trackers and analytics scripts inlined into the HTML often take up tens of KB. If your e-shop has 150 KB of inline JavaScript, every page will be 150 KB larger and the browser cannot cache that code. Moving it into external files with async or defer attributes solves this.

## How be1st checks it

Measures the size of inline JavaScript code directly in the HTML document. Small inline scripts are fine for critical functionality, but large blocks increase HTML size, slow down parsing, and prevent script caching and optimization. The check passes up to 10 KB, or up to 30 KB for modern SSR frameworks; hydration data and structured data (JSON-LD) are not counted.

[SEO + Security + Performance](https://be1st.ai/tools/ssp-audit), Performance tab.

Every check ends as: Pass, Warning, Fail.

## Sources

- [Remove unused JavaScript](https://developer.chrome.com/docs/lighthouse/performance/unused-javascript) (Chrome for Developers)
- [General HTML performance considerations](https://web.dev/learn/performance/general-html-performance) (web.dev)
- [Web Performance](https://developer.mozilla.org/en-US/docs/Web/Performance) (MDN Web Docs)

## Related terms

- [HTML size (performance)](https://be1st.ai/glossary/performance/html-size): HTML size is the weight of a page's HTML document in kilobytes. The browser has to download and parse all of it before it can show the page.
- [Structured data](https://be1st.ai/glossary/seo/structured-data): Structured data is machine-readable markup, usually JSON-LD with the Schema.org vocabulary, that says what a page contains: a product, an article, a company or an event.
- [Image optimization](https://be1st.ai/glossary/performance/image-optimization): Image optimization means serving images in the right size and format and loading the ones below the fold only when they are needed.
- [Total page weight](https://be1st.ai/glossary/performance/total-page-weight): Total page weight is the combined size of everything a page downloads: HTML, CSS, JavaScript, images and fonts.
- [Request count](https://be1st.ai/glossary/performance/request-count): Request count is the number of HTTP requests a browser makes to load a page. Every file, from a script to an icon, is one request.
- [CSS coverage](https://be1st.ai/glossary/performance/css-coverage): CSS coverage is the share of a page's downloaded CSS that the page actually uses. The rest is unused code the browser still has to process.
