v147 · Performance · demo

JSON Preload Race

Two simulated JSON module imports race: one with a <link rel="modulepreload" as="json"> hint, one without. The timing bars show time-to-data for each approach.

Click above to simulate both approaches.

No preload hint

baseline
Time to data available

With modulepreload

Chrome 147
Time to data available
<!-- Add this in <head> alongside other preloads -->
<link rel="modulepreload" as="json" href="/config.json">

<!-- Later, your ES module can import it instantly: -->
<script type="module">
  // The browser already fetched and parsed config.json
  // thanks to the modulepreload hint above.
  import config from '/config.json' assert { type: 'json' };
  console.log(config.version); // no network wait
</script>

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗