explaingit

webpack/webpack-bundle-analyzer

12,673JavaScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A webpack plugin that generates an interactive visual map of your JavaScript bundle, showing which libraries and files take up the most space so you can find and fix what's slowing down your page loads.

Mindmap

mindmap
  root((Bundle Analyzer))
    What it does
      Visual bundle map
      Size by file and lib
      Three size views
    Output Modes
      Browser server
      Static HTML file
      JSON for CI
    Use Cases
      Find large libraries
      Spot accidental deps
      Reduce load times
    Setup
      Webpack plugin
      Dev dependency only
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Find which third-party library is responsible for making your JavaScript bundle unexpectedly large.

USE CASE 2

Spot dependencies that accidentally ended up in your production bundle and should have been excluded.

USE CASE 3

Share a standalone HTML diagram of your bundle with a teammate to plan optimization work together.

USE CASE 4

Automate bundle size checks in CI using JSON output mode to fail the build if a chunk exceeds a size limit.

Tech stack

JavaScriptwebpackNode.js

Getting it running

Difficulty · easy Time to first run · 5min

Only works with webpack builds, add as a devDependency and register the plugin in your webpack config.

No license information was mentioned in the explanation.

In plain English

When you build a web application, a tool called webpack takes all your JavaScript files, libraries, and dependencies and packages them into one or more compressed output files called bundles. These bundles can grow large over time, and it is often unclear which libraries are responsible for most of the size. This tool, Webpack Bundle Analyzer, solves that problem by creating a visual map of what is inside each bundle. After you add it to your webpack build, it generates an interactive diagram where each rectangle represents a file or library inside the bundle. Larger rectangles mean larger size contributions. You can click and zoom into any section to explore what is nested inside it. The diagram also shows sizes in three ways: the raw size before any compression, the size after standard gzip compression, and the size after Brotli compression (a newer format that often produces smaller files than gzip). The tool runs in a few different modes. The default mode starts a small local web server and opens the diagram automatically in your browser each time you build. A static mode saves the diagram as a standalone HTML file you can share with a teammate. There is also a JSON output mode for automated checks or custom tooling. A command-line version lets you analyze an existing webpack stats file without modifying your build config. The main use cases, as the README describes them, are finding out what is actually inside your bundle, spotting which libraries take up the most space, catching dependencies that ended up in the bundle by accident, and identifying opportunities to reduce the overall size. Smaller bundles mean faster page loads, which matters especially for users on slow connections or mobile devices. This is an official package under the webpack GitHub organization and is installed as a development dependency, meaning it is only used during the build process and does not affect what ships to end users.

Copy-paste prompts

Prompt 1
I added webpack-bundle-analyzer to my project and the treemap opened. How do I read it? What does a large rectangle mean, and what is the difference between the stat, parsed, and gzip sizes?
Prompt 2
My webpack bundle is 2MB and pages load slowly. Walk me through using the bundle analyzer to identify which libraries I should lazy-load or replace to get under 500KB.
Prompt 3
How do I configure webpack-bundle-analyzer in static mode to generate a standalone HTML file I can share with my team instead of opening a browser automatically?
Prompt 4
How do I use the JSON output from webpack-bundle-analyzer in a CI pipeline to automatically fail the build if any single chunk is larger than 200KB?
Open on GitHub → Explain another repo

← webpack on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.