Code Monkey home page Code Monkey logo

awesome-webpack-perf's Introduction

Awesome Webpack Perf Awesome

A curated list of webpack tools and plugins that help make the web faster

Contents

Built-in stuff

  • mode: 'production' in the webpack config enables the common production optimizations
  • optimization.splitChunks in the webpack config enables splitting one bundle into smaller chunks. This helps to load less JS for each page and cache better

JS minifiers

JS minifiers are tools that make JS payloads smaller.

CSS

Minifiers

CSS minifiers are tools that make the volume of CSS smaller.

There’re three popular competing CSS minifiers: CSSO, CSS Nano and Clean CSS. They’re mostly similar in the compression quality and supported features, so if you’re picking one, just choose the one you prefer more.

Other optimizers

  • purgecss-webpack-plugin analyzes the app code and styles and removes CSS rules that aren’t used anywhere. Works great with CSS frameworks like Bootstrap

Extraction plugins

By default (with a simple style-loader), all styles imported in the app are added into the JS bundle. CSS extraction plugins help to move these styles into a separate .css file – which helps with faster rendering and better caching.

Critical CSS plugins

Critical CSS is an approach for rendering the site faster. With Critical CSS, for each page, you extract the rules needed for the initial render and inline them. Then, you load the remaining styles asynchronously. TODO: link to more details

CSS-in-JS

CSS-in-JS libraries typically provide Critical CSS support out of the box and need fewer manual optimizations. However, they still need minification.

Minification

Images

Image compression tools

All the tools below use imagemin and imagemin plugins for optimizing images, so they typically result in a similar level of compression.

You should prefer plugins over loaders. Plugins will optimize images that were produced by other loaders or plugins, whereas loaders will only trigger for files from your source code.

Other tools

  • lqip-loader generates low-quality image placeholders which you can use for lazy-loading images. Just like in Medium:

  • webp-loader converts images to webp

  • responsive-loader resizes one image to multiple various sizes. Works great with <img srcset> or <picture>

  • svg-url-loader generates 20-30% smaller data-urls for inline SVG images

Fonts

Gzip/Brotli

Gzip/Brotli compressors compress text so it’s smaller when served over the network.

Normally, this is done by a server like Apache or Nginx on runtime; but you might want to pre-build compressed assets to save the runtime cost.

Service workers

Both plugins below generate a service worker that prefetches all webpack assets in the background and adds offline support into the application:

  • workbox-webpack-plugin prefetches all webpack assets in the background and makes the app ready for working offline. It is based on Google’s workbox library that simplifies common usages of service workers
  • offline-plugin also prefetches all webpack assets in the background and makes the app ready for working offline. It falls back to AppCache in browsers that don’t support service workers

<link rel> and <script async>

¹ Asynchronous chunks are chunks that are created when you use dynamic import()

Prerendering

Prerendering tools run an app during the build and return the HTML the app generates. This is an alternative to server-side rendering and helps to deliver the content to the user immediately – instead of making them wait until the bundle is loaded.

Progressive web apps (PWA)

Analysis tools

  • webpack-bundle-analyzer generates a view of the bundle content. Use it to figure out what takes so much size in the bundle:

    (Animation credits: webpack-bundle-analyzer)

  • source-map-explorer also generates a view of the bundle contents. It’s less detailed than webpack-bundle-analyzer but only needs a source map to run:

    (Image credits: source-map-explorer)

  • Webpack Analyse shows all modules present in the bundle – and relationships between them. Use it to understand why a specific suspicious module is bundled:

  • Bundlephobia reports bundle sizes of JS libraries:

Build-time audit tools

  • webpack-dashboard reports sizes of modules and warnings like duplicated files during development:

    (Image credits: webpack-dashboard)

  • duplicate-package-checker-webpack-plugin prints a warning if a bundle includes multiple versions of the same library:

    (Image credits: duplicate-package-checker-webpack-plugin)

Other web performance lists

  • Awesome WPO – A curated list of Web Performance Optimization
  • Webpack Libs Optimizations – A collection of Babel and webpack plugins to optimize the size of various popular libraries

Contribute

Contributions welcome! Read the contribution guidelines first.

License

CC0

To the extent possible under law, Ivan Akulov has waived all copyright and related or neighboring rights to this work.

awesome-webpack-perf's People

Contributors

iamakulov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.