218 KB of Dictionary on Every Page: How to Find and Strip Bloated Payload in NuxtArticle · digest for November 10
X-ray cross-section of a web document structure revealing hidden data blocks inside the page
Article4 sections≈ 9 min

218 KB of Dictionary on Every Page: How to Find and Strip Bloated Payload in Nuxt

In a November audit of 36 production sites from the Nuxt Showcase, one number caught my eye: the median size of the hidden state block inside a document is 93 KB, eating 29% of the markup volume. Teams usually blame slow loads on heavy images or JS bundles, assuming HTML is a lightweight shell. In reality, 17 projects cross the yellow threshold of 100 KB, 6 sites smash past the 500 KB red line, and several major stores ship 120 to 280 KB of localization dictionaries inside the home page's markup.

The esports platform BIGPLAY on Nuxt fell into the same trap: a clean home page ballooned past half a megabyte of text, even though a guest only needs to see a couple dozen phrases. Let's look at how hydration turns state into network ballast, how to inspect a site with nuxt-payload-xray, and how to move translations into a permanent cache.

The Invisible Weight of Hydration: Why Nuxt Hides State Inside HTML

With Server-Side Rendering, the browser receives ready-to-paint markup right away. Next comes client-side JavaScript, which has to "hydrate" the page—attaching click handlers and booting menus.

It is like shipping a pre-assembled kit by mail: so you can flip switches immediately without calling the factory, a manifest of settings is packed into the box. Without those details, the browser would have to re-query the backend after scripts load, causing screen flicker. So the framework collects state from useState, useAsyncData, useFetch, and stores, and writes it at the bottom of the HTML inside <script type="application/json" id="__NUXT_DATA__">.

Inside that tag, data sits as a flat array with index references: element zero points to the root, and repeated strings are written once. Deduplication saves space on repeats, yet triggers a chain reaction:

  • if you put a lookup table or an entire API response into state during a server request, the serializer packs the whole thing into the array;
  • because the block is embedded in HTML, the browser cannot cache it across visits like a static script—refreshing a tab or arriving from search downloads the entire payload all over again;
  • and if the browser has to parse hundreds of kilobytes of JSON on the main thread before hydration, mobile UIs freeze.

During local development, this is easy to miss: navigating via NuxtLink skips fetching new HTML and reads state from memory. Everything flies on an engineer's laptop while search visitors wait on bloated markup.

X-Raying the Server Response: How nuxt-payload-xray Spots Heavy Keys

Standard speed auditors only complain about oversized HTML without naming the culprit key inside __NUXT_DATA__. Nuxt's built-in devtools only show key weights locally in dev mode, and static analyzers only inspect _payload.json when building with nuxt generate.

In a write-up on Habr, BIGPLAY developer Dauren (dadashi44) explained how he built nuxt-payload-xray to inspect live servers. It fetches a page by URL without needing source access, locates __NUXT_DATA__, walks the array references from the data, state, and pinia keys, and calculates the weight of each branch.

Let's inspect the heaviest keys on a live site from the terminal and enforce a size budget for a staging preview in CI/CD:

# Inspect the heaviest payload keys on a live page
npx nuxt-payload-xray https://nuxt.com --top 10

# Enforce a weight limit in CI/CD, returning an error code if exceeded
npx nuxt-payload-xray "$PREVIEW_URL" --max 150kb

The first command downloads the markup and prints a breakdown: raw and gzipped payload size, share of HTML, and a key ranking. The second command with --max guards the build: if a preview page exceeds 150kb, the script exits with code 1 and halts the deploy.

Measuring nuxt.com itself is telling: the data payload weighs 196.6 KB raw or 51.3 KB gzipped—36% of the 546.3 KB document. Leading the pack is data: navigation:4.x at 77.7 KB, followed by data: index at 49.6 KB and data: official-modules at 40.4 KB. Inside navigation:4.x sits a menu of 429 documentation sections for instant Ctrl+K search. That gives a clear rule of thumb: a large key that the page genuinely needs in full is an honest price for a feature; a large key of which you only use a tiny slice is a bug.

The Localization Trap: How an Entire Site's Dictionary Ends Up in Every Page

When Dauren scanned BIGPLAY's home page before optimization, uncompressed HTML weighed 658 KB, with 271 KB taken up by the hydration payload. Inside sat a translations key weighing 218 KB—2,271 lines of translations for the entire portal, including the account dashboard and profile settings.

The cause was a deceptively convenient pattern: server middleware fetched translations from an external service, and a plugin stored them in useState('translations') so localization worked on both server and client. Because useState syncs data to the browser, the framework serialized the entire dictionary into every page.

UI copy changes rarely, so the dictionary was moved into a standalone file. The server computes the dictionary's SHA-1 hash and serves it at /i18n/ru.<hash>.json with Cache-Control: public, max-age=31536000, immutable, caching the file for a year.

Here is how the code changed: instead of keeping the dictionary in useState, only a short version hash remains, while <head> preloads the file:

// Before: the entire dictionary goes into useState and serializes into HTML
// const translations = useState('translations', () => ({}))

// After: only a short SHA-1 version hash of the dictionary stays in payload
const translationVersion = useState('i18n_ver', () => 'a1b2c3d4e5f6')

useHead({
  link: [
    {
      rel: 'preload',
      href: `/i18n/ru.${translationVersion.value}.json`,
      as: 'fetch',
      crossorigin: 'anonymous'
    }
  ]
})

Now __NUXT_DATA__ only carries the twelve-character string 'a1b2c3d4e5f6'. The server still renders HTML with the full dictionary from memory for search engines, while <link rel="preload" as="fetch"> tells the browser to download the JSON in parallel with the document. I paid special attention to crossorigin="anonymous": without it, the CORS mode will not match fetch(), and the browser will download the dictionary twice. I also covered route-level resource preloading in Nuxt Ecosystem: Per-Route Font Preloading and Faster Icon Rendering.

During rollout, they dodged two more traps. First, you cannot put the file under /api/ if that path is blocked in robots.txt: otherwise Googlebot cannot fetch the dictionary and indexes raw keys—which is why they chose /i18n/. Second, cached HTML might request a stale hash after a translation update—I wrote about caching rules in Nuxt v4.6.4: Urgent Security Release, Host Checking, and New Nitro Caching Rules. To keep pages from breaking, the server keeps recent dictionary versions in memory and serves the latest dictionary with Cache-Control: no-store for any unknown hash.

Production Results and Knowing Where to Stop Optimizing

Re-running nuxt-payload-xray on bigplay.gg showed a clean win: uncompressed home page HTML dropped to 191.6 KB, and the hydration block shrank to 55.9 KB raw or 15.7 KB gzipped, while in the test benchmark summary the payload compressed from 256 to 47 KB. Now 97% of the payload—54.3 KB—is the data: home-page-ru key with tournaments and banners, while the pinia: tournamentsPageStore and pinia: translationState stores weigh 172 B and 132 B.

In production gzipped builds, the per-route savings look like this:

Portal PageHTML Size: Before → AfterPayload Size: Before → After
Home112 KB → 59 KB66 KB → 12 KB
English version /en96 KB → 58 KB50 KB → 12 KB
Tournaments list101 KB → 48 KB56 KB → 3 KB

On a first visit, network savings are nearly zero because the 53 KB gzipped dictionary is fetched as a separate file. On repeat visits, however, the dictionary comes from cache at 0 bytes, cutting page weight in half.

What wins me over in this case study is the author's math on why you should not slice the dictionary further per page:

  • If you split by section, the header, footer, and modals appear everywhere and already pull in 68–82% of the dictionary.
  • If you split by key, a page uses 21–32% of strings, but static analysis only finds 58% of keys in code—the rest are assembled dynamically, and a parser miss would show users raw tournament_page.xxx keys.
  • If you compare download streams, the dictionary downloads in parallel with the home page's 317 KB gzipped JS bundle. Interactivity begins after JS finishes loading, so shrinking the dictionary further will not speed up response time.

To keep server responses lean in your own projects, follow three working principles:

  • X-ray pages by URL: run npx nuxt-payload-xray <url> on key routes and check what share of heavy keys is actually visible on screen.
  • Trim unused API fields: in useFetch('/api/tournaments', { pick: ['id', 'title', 'startDate'] }), use pick to keep only what the template needs and never dump raw backend responses into stores.
  • Move static data out of useState: serve rarely changing translations, lookup tables, and configs as separate hash-cached files.

The first step captured nearly all the gains without risking a broken UI, and knowing when to stop instead of building a fragile parser for pennies of savings is engineering pragmatism at its finest.

Want a deep diveVotes help us choose what to break down in detail. This material has 0 votes.
Sources · 2