i18n Performance: Budgeting the Localization Layer

i18n Performance: Budgeting the Localization Layer

Catalogs, library runtime, and locale data itemized: split by locale and namespace, prevent the flash of untranslated content, cache formatters, measure the heaviest locale.

"i18n is heavy" is folklore until the bill is itemized. The layer has three line items: message catalogs, library runtime, and locale data. Locale data costs bytes whenever an app has to ship it itself, but it is nearly free when the browser's built-in Intl supplies it. This article covers splitting catalogs by locale and by namespace, loading strategies and the flash of untranslated content, the runtime cost of formatters and message parsing at render scale, server-side formatting as a weight-shifting lever, honest polyfill decisions, and measuring the layer on the heaviest locale rather than on English.

Itemizing the bill

The i18n layer's weight has exactly three line items, and they behave very differently.

Line itemHow it scalesTypical lever
Message catalogsGrows with product surface multiplied by localesSplitting by locale and namespace
Library runtimeFixed, chosen onceLibrary choice and precompiled messages
Locale dataNear zero with built-in Intl; real when polyfilledRelying on the platform; per-feature polyfill decisions

The good news belongs first, because it is the reason this layer can stay manageable. The locale data for formatting dates, numbers, currencies, lists, and plural categories ships inside the browser and, in default Node.js builds, inside the JavaScript runtime. Which locales are covered is implementation-defined (ECMA-402 §4.4), and Node.js also offers build options that link to the system's ICU, embed only a subset of ICU data, or leave ICU out entirely. The Intl API exposes that engine-supplied data without the page downloading any of it; ECMA-402 recommends, but does not require, that implementations use the locale data provided by the Unicode CLDR project. A standards-first i18n approach is also the performance-first approach: every formatting job handed to Intl is data the bundle does not carry.

The failure mode this article exists to prevent is simple and common: all locales, all namespaces, one bundle. A site with twenty locales that bundles every catalog makes each visitor download nineteen languages they will never read, and the cost grows every time a feature or a locale is added.

Scope: this is the i18n-specific budget. Loading-performance methodology at large, including Core Web Vitals, waterfall analysis, and general budgeting practice, belongs to the core-web-vitals literature; this article assumes the team already has those tools and adds the i18n lines to them.

Catalog splitting: the two axes

Catalogs split along two axes, and only one of them is optional.

Axis one, by locale, is non-negotiable. A user in one locale downloads that locale's catalogs and nothing else. The resolved locale, the one the routing layer has already settled on for the request, selects the payload. Shipping any other locale's messages to that user is waste by definition, with one deliberate exception: a fallback locale's strings when the current catalog is incomplete, loaded only for the keys that are missing.

Axis two, by namespace or route, is a trade-off. If keys are organized into namespaces along feature lines, such as checkout, account, and search, catalogs can load with the routes that use them, while a shared namespace for global chrome loads once. This is where an early key-architecture decision pays off: namespaces that follow product areas split cleanly, while a single flat namespace cannot be split without restructuring keys.

The granularity trade-off deserves honesty. Per-route splitting minimizes the first-load payload, but it multiplies requests, adds loading states to every navigation, and complicates caching. Coarser splits, such as a common bundle plus a few large feature bundles per locale, are often the boring right answer, because catalog files compress well and the request overhead of many tiny files can outweigh the bytes saved. Which side wins depends on catalog size and navigation patterns, and it should be measured rather than assumed.

What ships to the client should also be the compiled form of the catalog, not the interchange form. Translator notes, source references, and length hints are valuable in the files translators work with and useless in the browser. Strip them at build time, and where the toolchain supports it, ship precompiled messages instead of message source strings.

javascript
// Build output per locale and namespace, not one global file
// /i18n/de/common.json      loaded once, with the app shell
// /i18n/de/checkout.json    loaded with checkout routes
// /i18n/de/account.json     loaded with account routes

async function loadMessages(locale, namespaces) {
  const files = await Promise.all(
    namespaces.map((ns) => import(`./i18n/${locale}/${ns}.json`))
  );
  return Object.assign({}, ...files.map((f) => f.default));
}

The dynamic import pattern above lets the bundler emit one chunk per locale and namespace, the same mechanism that code splitting uses for components.

Loading strategies and their failure modes

There are three ways to get the right catalog to the client, and each has a characteristic failure.

  • Bundled with the route. The catalog chunk loads alongside the route's code. This is simple, and payload follows code splitting automatically. The failure mode is coupling: a route's catalog cannot load until its code does.
  • Fetched on demand. The catalog is requested after the locale and route are known. This produces the smallest initial payload. The failure mode is an extra request on the critical path, and, if unmanaged, a flash of raw keys or source-language text while it is in flight.
  • Inlined in the HTML for the critical namespace. The strings needed for first paint arrive with the document. This gives the fastest first paint of correct text. The failure mode is weight on every document, including repeat visits that already had the catalog cached.

The flash of untranslated content is this layer's specific rendering hazard: text that appears as keys, or in the source language, and then changes to the user's locale once a catalog arrives. It looks broken, it shifts layout, and screen readers may announce the wrong text. Prevent it structurally rather than cosmetically. Either the server renders with the critical catalog already available, or the critical namespace is inlined. Hiding content until the catalog arrives trades a flash for a blank page, which is not a fix.

Locale switching is the edge case that reveals whether the loading design is real. Switching from English to German should load German catalogs for the namespaces in use, and nothing else; if it re-downloads the application or reloads the page to get there, the catalog boundary exists in name only.

Preloading is the cheap optimization that respects the split. Once the resolved locale is known, hint the namespaces the user is likely to need next, such as checkout from the cart page, so the split does not cost a visible wait.

Runtime cost: formatters and messages at render scale

Bytes are only half the bill. The other half is work done on every render.

Creating an Intl formatter can cost more than reusing one. MDN notes that every toLocaleDateString() call has to search a big database of localization strings, which is potentially inefficient, and that when the method is called many times with the same arguments it is better to create an Intl.DateTimeFormat object and use its format() method. The DateTimeFormat constructor has to resolve the locale, negotiate options, and load data for the combination; calling format() on an existing instance reuses that resolved locale and those options rather than negotiating them again. One hot-path bug is constructing a formatter inside a list row, so a table of five hundred rows builds five hundred identical formatters. A cache keyed by locale and options applies the create-once, reuse-many advice across components:

javascript
const cache = new Map();

export function dateFormatter(locale, options) {
  const key = locale + JSON.stringify(options);
  let fmt = cache.get(key);
  if (!fmt) {
    fmt = new Intl.DateTimeFormat(locale, options);
    cache.set(key, fmt);
  }
  return fmt;
}

// In the row: dateFormatter(locale, { dateStyle: "medium" }).format(order.date)

Message evaluation has a similar shape. ICU-style messages can be parsed at runtime from their source strings or compiled ahead of time into data structures or functions that skip parsing. Some toolchains document this as a build step, for example FormatJS's precompilation guidance (as of Nov 2026). The same guidance notes that precompiling skips runtime parsing but does not remove the parser from the bundle: in react-intl, after all messages and default messages are precompiled, a build alias can replace the parser with a no-parser module, which throws if a message still needs parsing. The size of the difference between runtime parsing and precompiled messages depends on the library, the message volume, and how often messages are re-evaluated, so it belongs on the list of things to measure in the team's own stack rather than something to quote as a universal number.

Server-side formatting is the lever that shifts the cost off the client entirely. If dates, numbers, and messages are formatted during server rendering, the client may not need the formatting library or locale data for that content at all. The price of the lever is consistency: when the client hydrates or re-renders the same values, it must use the same locale, time zone, and options as the server, or the output differs and hydration produces mismatches. The lever works when those inputs are passed explicitly from server to client rather than re-derived on each side.

Polyfills deserve the same honesty. Shipping a polyfill for an Intl formatter such as Intl.NumberFormat means shipping its locale data as well, loaded per locale, and that data adds to the payload. A polyfill for a newer date-time API such as Temporal may instead rely on the built-in Intl for formatting, so check what each polyfill actually bundles. The decision is per feature and per audience: which runtimes in the site's real traffic lack the feature, checked against current compatibility data at the time of the decision. Loading a polyfill conditionally, only where the feature is missing, keeps the cost on the browsers that need it. A blanket "polyfill everything for safety" habit puts that weight on every visitor, including visitors whose browsers already have the feature built in.

Measuring the layer, not the folklore

The i18n layer earns a line in the team's existing performance budget, measured with the tools the team already runs. Three measurements cover most of it:

  1. Catalog bytes per route per locale, compressed, as served.
  2. The i18n runtime's share of the JavaScript bundle, from the bundle analyzer the build already uses.
  3. Formatting and message time in profiled hot paths, such as long lists and data tables.

The bundle analyzer is also where accidental locale data shows up. A common pattern is a date or number library that ships its own per-locale data files, imported in a way that pulls every locale into the main chunk even though only one is used per visitor. In the analyzer it looks like a directory of dozens of small files with locale codes for names, sitting in the main bundle. The fix is either to import only the locales the site supports, loaded per request the same way catalogs are, or to replace that formatting path with built-in Intl where it covers the need. Either way, the evidence is in the analyzer output, not in a library's marketing claims about size.

Measure the heaviest locale, not English. Payloads differ by locale: messages in some languages are longer, some locales need polyfills that others do not, and scripts with large character sets can change font loading costs. A budget that passes in English and fails in the heaviest locale is a budget measured on the narrow case.

The regression risk is quiet growth. Catalogs gain keys as features ship, and keys whose features are removed stay in the catalog until someone or something deletes them. A size check on compiled catalog artifacts in CI, added to the same pipeline that already validates catalog syntax, catches creep at the pull request that caused it rather than much later in a performance review.

The honest closing point is reassuring. A well-split i18n layer can be cheap when the platform carries the locale data and catalogs compress well. The point of budgeting it is to keep it cheap as locales and features multiply, not to treat internationalization as a performance problem to be feared.

Project Inquiry