Index of every page on this site: llms.txt

Nuxt SEO Utils automatically minifies inline <script> and <style> tags at build time. Runtime minification is opt-in.

How It Works

The module provides two complementary minification modes that can be toggled independently.

Build Mode

At build time, the module has access to native tooling for full minification:

  • JavaScript: Minified with Rolldown (Vite 8+) or esbuild (Vite 7), automatically detected
  • CSS: Minified with lightningcss (full CSS optimization)

This applies to:

  • Static scripts and styles defined in app.head within your nuxt.config
  • JSON scripts and inline styles in prerendered/generated route HTML

Runtime Mode

For dynamic SSR where scripts are generated per request (hydration payloads, useHead() injections), the module registers an Unhead ssr:render plugin that minifies HeadTag content before it's serialized to HTML.

Runtime mode compacts JSON scripts and inline CSS. It preserves JavaScript, import maps, speculation rules, and custom script types.

JavaScript minification needs a parser. The module runs parser-based JavaScript minification only at build time.

Build mode uses parser-based minifiers and has no runtime cost. Runtime mode adds work to every SSR request. Enable it only after measuring the transfer savings and CPU cost for your application.

Configuration

Build mode is enabled by default. You can configure both modes in your nuxt.config:

export default defineNuxtConfig({
  seo: {
    minify: { build: true, runtime: false },
  },
})

What Gets Minified

ContentBuild ModeRuntime Mode
app.head scripts/stylesRolldown or esbuild / lightningcssn/a (static)
Prerendered route HTMLJSON / lightweight CSSn/a (static)
Dynamic JavaScriptPreservedPreserved
useHead() JSON scriptsJSONJSON
useHead() injected stylesn/a (dynamic)Lightweight CSS

What Gets Skipped

The following are skipped by the JS minifier:

  • JSON script types (application/ld+json, application/json) are minified via JSON.parse/JSON.stringify instead of JS minification
  • importmap and speculationrules script types are left completely untouched
  • External scripts (with src attribute)
  • Custom script types are preserved at build time and runtime
  • Dynamic JavaScript is preserved during SSR and prerendering
Was this page helpful?