Skip to content

Instantly share code, notes, and snippets.

@ramasilveyra
Last active November 6, 2016 06:55
Show Gist options
  • Save ramasilveyra/e42baca844a9b8f1cf51397c92d26b5f to your computer and use it in GitHub Desktop.
Save ramasilveyra/e42baca844a9b8f1cf51397c92d26b5f to your computer and use it in GitHub Desktop.
Preload/prefetch JS files (for code splitting and async routes)

Preload/prefetch JS files (for code splitting and async routes)

Preload/prefetch JS files techniques to avoid waterfall when you split the main bundle in chunks (async routes).

Results of chunks files

Approach JS executed Loaded as Support
link rel preload as script false JS File -
link rel prefetch false File +
script async defer in body true * JS File ++
script async defer in head true * JS File ++

* On Webpack 2 throws Uncaught ReferenceError: webpackJsonp is not defined. Not tested on webpack 1 but I guess a similar error.

Support (Can I use)

More info about JS code split and async routes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment