SEO check

JavaScript Minification

What JavaScript minification is, how our report decides a script is minified, and the fastest ways to fix unminified files.

Free to use 9 min read Updated Oct 2026

What Is JavaScript Minification? The Quick Answer

Quick answer: JavaScript minification strips whitespace, comments and long names from a script so the file is smaller and quicker to download and parse, while the code behaves the same. Our report downloads your external script files and checks whether each script file looks minified.

  • Pass: every external script file the report checked looks minified.
  • Warning: a mix of minified and unminified JavaScript files.
  • Fail: none look minified, none could be fetched, or the page has no external script.
  • Fix: build with a minifier such as Terser, or switch your bundler to production mode, then serve the .min.js or hashed file it produces.

Check my website

What JavaScript Minification Does to Your Code

To minify JS is to minimize JavaScript without changing what it does. A minifier strips whitespace and comments, then mangles variable names down to a letter or two. Better ones such as Terser add dead code elimination and fold constant expressions, the compress step in the command later. Source maps show your original lines in DevTools. The MDN minification glossary entry defines it neutrally.

Before and after on a small function

A readable function comes first, then what a minifier typically writes.

JavaScript
// source
// add sales tax to a price
function addTax(price, rate) {
  var total = price * (1 + rate);
  return total;
}

// minified
function addTax(n,t){return n*(1+t)}

The comment, indentation, temporary variable and long parameter names are gone, yet addTax(100, 0.2) still returns 120.

Minification vs compression vs obfuscation

Minification changes the file itself during your build. Gzip and Brotli compression packs the bytes in transit, and the two stack (our gzip compression guide covers that side). Obfuscation vs minification comes down to intent: obfuscation tries to hide logic and often makes the file bigger, while a minified file is only harder to read, not protected.

Why Minifying JavaScript Matters for Speed and SEO

We compressed jQuery 3.7.1 in both forms; gzip figures vary by a few hundred bytes between implementations.

VersionRaw bytesgzip level 6Brotli quality 5
Source as published285,314about 84,00079,680
Minified (jquery.min.js)87,533about 30,40029,763
Saving from minifyingabout 69 percentabout 64 percentabout 63 percent

The last row matters most. Even when the server already compresses text (the audit Lighthouse calls Enable text compression), minifying first still cuts roughly two thirds of the bytes sent. That is a big cut in JavaScript file size for what is usually one build setting.

Smaller scripts download sooner on slow connections and give the browser less to parse, which contributes to Largest Contentful Paint, one of the Core Web Vitals. That is a contribution, not a ranking switch. When parsing blocks the main thread it also touches Interaction to Next Paint, and heavy third party code still causes long tasks, and our JavaScript execution time guide covers that.

How SEO Site Checker Tests JavaScript Minification

The test is a line length heuristic you can reproduce by hand.

The rule: for each external script file, divide the total characters by the number of lines. An average line length above 200 characters counts as minified. 200 or below counts as unminified.

What the check reads

We render your page in headless Chromium and parse the final HTML, so scripts added by JavaScript are seen too. We collect the first 8 external script tags in page order and skip inline code, because there is no file to download for it. Each file is fetched on its own with a 3 second timeout, and the whole batch gets about 10 seconds.

How one file is judged

In our tests jQuery 3.7.1 source averaged 25.6 characters per line and was flagged, while jquery.min.js averaged 43,765. The lodash 4.17.21 build averaged 520 and the React 18.3.1 production build averaged 346, so both passed. A file we cannot fetch is counted as unminified.

Pass, warning and fail

StatusConditionWhat to do
PassedAt least one file fetched and none of the checked files is unminifiedNothing to change
WarningAt least one file is minified and at least one is notMinify the files that missed
FailedNo file looked minified, every fetch failed, or the page has no external script fileMinify, confirm the files load, or ignore it if the page really has no external scripts

The report also shows how many files it checked (8 at most) and, once you sign in, the minified and unminified URLs.

Known blind spots

Line length is only a proxy, so it can be wrong.

  • Banner comments. A small file with a long license banner can fall under the limit: our 1,152 byte test file minified with Terser averaged 128 and was flagged.
  • Wrapped output. Output wrapped near 120 characters is flagged too: jQuery wrapped that way averaged 99.5.
  • Scheme relative URLs and timeouts. A scheme relative URL starting with // counts as unminified. So does a file that fails to download, and the 10 second batch limit can leave slow files out of the count.
  • Path joining. Relative paths such as js/app.js are joined to your site root, not the page, so on a nested page we may fetch a different file from the one the browser loads.

This scan also feeds caching, covered in our JavaScript caching guide. To see your own numbers, run the free SEO report on your URL.

Check my site free

How to Check if JavaScript Is Minified

  1. Open the file. Minified JavaScript is a few dense lines of short names.
  2. Compare in DevTools. In the Chrome DevTools Network panel, filter by JS, reload and compare size with transfer size.
  3. Measure the line length. Swap /js/app.js below for your own script path and run it in the console on the same site, since other origins may block the fetch. Above 200 matches our rule closely.
JavaScript
fetch('/js/app.js')
  .then(r => r.text())
  .then(t => console.log(t.length / t.split('\n').length));

If your Lighthouse or PageSpeed Insights version includes it, the Lighthouse Minify JavaScript audit lists estimated savings in KiB. It documents no pass threshold, so it and our rule can disagree on edge cases.

How to Minify JavaScript Files Step by Step

Use a one-off command or a build setting that minifies on every deploy.

  1. Keep readable source. Generate minified copies during the build, never by hand.
  2. Quick route with Terser. Install it with npm and run the command below. The -c flag compresses and -m mangles names, and the source map it writes lets DevTools map errors back to src/app.js (drop the source map option if you do not want a map file).
  3. Bundler route. Code splitting and bundling reduce how many scripts a page loads, and minification shrinks what remains. Webpack production mode minimizes output through TerserPlugin, so set mode to production. Vite minifies during vite build by default, though the minifier depends on the version (current docs name Oxc, older releases used esbuild).
  4. Update the script tag. Point it at the new .min.js file or hashed bundle and remove the old reference.
  5. Test and re-scan. Click through forms and payments, then run the report again.
Text
npm install terser --save-dev
npx terser src/app.js -c -m --source-map "url=app.min.js.map" -o dist/app.min.js

UglifyJS, SWC, esbuild, Rollup plugins and Google Closure Compiler do similar work, and tree shaking trims what ships. The webpack optimization settings explain the minimize option. For a quick one-off job, our free JavaScript Minifier will shrink a pasted script without any setup, though for the report a build tool gives a safer result.

Tool limit: our minifier does not shorten names and keeps some line breaks, so a small file can still average under 200 characters per line.

A longer walkthrough is in our post on how to minify HTML, CSS and JavaScript.

How to Minify JavaScript in WordPress, Shopify and Cloudflare

Where the fix lives depends on who builds your scripts. Platforms handle some files for you and leave the rest to you.

PlatformWhere to startWatch out for
WordPressCore serves minified scripts unless SCRIPT_DEBUG is true in wp-config.phpThat covers core only, so theme and plugin files need a plugin
ShopifyShopify minifies theme CSS and ES5 JavaScript for youNewer syntax, apps and inline code are not covered, so minify those yourself and upload them as .min.js
CloudflareMinify during your build or at the originCloudflare Auto Minify has been retired
React and bundled appsDeploy the production buildA development build ships readable code
Third party scriptsAsk the vendor for a .min.js build or a hosted copy that is already minifiedRemove the tag only if you no longer need the feature

To minify JavaScript in WordPress, use a plugin. In Autoptimize, tick Optimize JavaScript Code on the JS, CSS and HTML tab. In LiteSpeed Cache, turn on JS Minify under Page Optimization, JS Settings.

Common JavaScript Minification Mistakes

  • Skipping the test. Code that reads function.name, builds names as strings, or is joined with other files without semicolons can break after minifying.
  • Losing the source. Deleting the original files or source map makes errors hard to debug.
  • Pointing at the old file. If the script tag still references the unminified URL, the report never changes.
  • Forgetting third party files. They are judged like yours, and one unminified file is enough for a warning.
  • Stopping at minification. Scripts that block rendering still need defer, which our render blocking resources guide covers.

How to Fix

The short version, the same steps you see when you click How to Fix in your report.

Why this fails: at least one script file on your page still has readable, indented lines and comments, or none of the files could be fetched. It can also trigger when your files are minified but small, wrapped near 120 characters or topped by a long license banner, or when the page loads no external scripts at all. Our check downloads up to 8 external scripts and treats an average above 200 characters per line as minified.

How to fix it:

  1. Open the unminified list in the report (sign in to see the URLs) or view the page source, and note which script files you own.
  2. Run Terser on each file you own, or switch your bundler to production mode so it minifies for you.
  3. Update each script tag to point at the new .min.js or hashed file, and remove the old reference.
  4. Ask the vendor of any third party file for a minified build, or remove the tag.

Terser command, with a source map:

Text
npx terser src/app.js -c -m --source-map "url=app.min.js.map" -o dist/app.min.js

webpack.config.js:

JavaScript
module.exports = { mode: 'production' };

Updated script tag:

HTML
<script src="/js/app.min.js" defer></script>
  • WordPress: switch SCRIPT_DEBUG off (it only affects core scripts), then enable JS minify in Autoptimize or LiteSpeed Cache for theme and plugin files.
  • Shopify: Shopify only minifies ES5 JavaScript and skips files already named .min.js, so minify newer syntax files yourself and check apps and inline code.
  • Cloudflare: it no longer minifies for you, so minify in your build or at the origin.

Average line length check (add -L to curl if the URL redirects):

Text
curl -s https://example.com/js/app.min.js | awk '{c+=length($0); n++} END {print c/n}'

Re-test: open the script URL and confirm a few dense lines, or print its average line length with the command above, where a result comfortably above 200 should pass. Then run our free SEO report again and look for Passed on JavaScript Minification.

Re-test my website

Frequently Asked Questions

Does minifying JavaScript improve performance?
Yes for download and parse time, because the file is smaller, and the gain is biggest on slow mobile networks and large bundles. It rarely changes how fast the code runs once parsed, so pair minification with compression and caching.
Is JavaScript minification the same as compression?
No. Minification rewrites the file itself during your build, while gzip or Brotli compress the bytes in transfer. Use both because they stack: in our test jQuery 3.7.1 fell from about 84,000 to about 30,400 bytes under gzip once minified first.
Will minifying JavaScript hurt my SEO?
Not when it is done correctly. Smaller files help pages load faster, and crawlers run the same code either way. The real risk is broken output, so test after every build and keep the readable source files.
How do I know if my JavaScript is already minified?
Open the file in a browser tab: dense lines and short variable names mean it is minified. Or run the free SEO report, which lists minified and unminified script links once you sign in.
How does this check decide a script is minified?
It averages the characters per line of each external script, for up to 8 files, and above 200 counts as minified. A small file with a long license banner, or output wrapped near 120 characters, can be misjudged, so a correctly minified file may still be flagged.
How do I minify JavaScript in WordPress?
First make sure SCRIPT_DEBUG is not set to true in wp-config.php. That setting only affects core scripts, so for theme and plugin files enable JavaScript minify in a free plugin such as Autoptimize or LiteSpeed Cache. Test checkout afterwards.
Do I still need to minify JavaScript if I use webpack or Vite?
Production builds minify by default, but development builds and plain static files do not. Confirm the live page loads the built files, then run the report to check every script.
Is minifying JavaScript the same as obfuscating it?
No. Minification aims at a smaller file and keeps behavior identical, while obfuscation aims at hiding the logic and can make the file larger. Minified code is hard to read but is not protected, so never rely on it for security.

See how your site scores right now

Paste your address into the free report, then use the How to Fix button on anything that needs work.

Free to use. Results in under a minute for most sites.