Chunking

This ad is not shown to multipass and full ticket holders
React Summit US
React Summit US 2026
November 17 - 20, 2026
New York, US & Online
Upcoming event
React Summit US 2026
React Summit US 2026
November 17 - 20, 2026. New York, US & Online
Bookmark
Rate this content
Sentry
Promoted
Code breaks, fix it faster

Crashes, slowdowns, regressions in prod. Seer by Sentry unifies traces, replays, errors, profiles to find root causes fast.

Get started

We look into how bundlers place modules into output files in a process called "chunking".

What are the competing metrics that can be influenced by chunking?

Why is CSS and JS chunking completely different?

What are performance considerations for large apps?

How does JS chunking and CSS chunking work in Webpack/Turbopack/Next.js (on a high level)?

This talk has been presented at JSNation 2026, check out the latest edition of this JavaScript Conference.

Tobias Koppers
Tobias Koppers
28 min
11 Jun, 2026

Comments

Sign in or register to post your comment.
Video Summary and Transcription
Tobias Koppers explains chunking in Bundlers, emphasizing efficient module grouping for performance optimization. Strategies involve smart module grouping, caching, and balancing between request counts and download sizes. CSS delivery via link tags poses complexity in chunking due to order dependencies. Balancing CSS chunking to reduce requests involves overshipping techniques. Evolving chunking strategies consider compile time challenges and the impact of React server components. Future optimizations may prioritize pages based on analytics data. Tailwind offers a solution for CSS chunking, while the need for future CSS features with native dependency declarations is highlighted.
Available in Español: Chunking

1. Understanding Chunking in Bundlers

Short description:

Tobias Koppers discusses chunking in Bundlers, where modules are placed into output files called chunks based on a module graph. Visualization involves drawing cycles around modules, grouping them into output files. Entry points and shared modules are separated into distinct chunks for efficient loading.

My name is Tobias Koppers, I work at Vercel as a tool pack team, and today another Bundler topic, chunking. So what is chunking at all? So my definition of chunking is it's a process in a Bundler that places module into output files. And I usually call these output files chunks because whatever, it came up with this name. So it's basically like we take the module graph of your application, decide in some weird way how to put it into like chunks, and that's chunking the process.

If you visualize it, there could be like a really simple example here. So we have a module graph, a really small one for this one. So we have a bunch of modules, these like white dots. These modules are usually connected via dependencies, like import, or acquire, or an async import. And these are the edges of the graph. And I visualize a really special edge here because it's really special for chunking, there's a red dashed one, that's an async import, so like a dynamic import or something where you load something on demand.

And also like, usually your module graph has a lot of empty points, maybe your pages or that stuff. And here are the most important pages of an application is, of course, the legal page and the pricing page. And you can basically visualize chunking in a way that you just draw cycles around these modules. And yeah, I did this with the screen cycles, and basically means like all of these modules that are cycled together are put into one output file. And yeah. And an example like this async import here on the left side, with the red dotted thing, is put into its own chunk so we can load it on demand.

And we have like all the entry points being its own chunks because then we can load them independent of the other pages. And you could also, like in this example, I also put like the middle area of modules that are shared by these two entry points into like its own chunks, so we can share that. But yeah, it's really complicated. You can come up with a lot of different ways to cycle these modules. And yeah, that's the process of chunking, not of cycling. Yeah.

2. Optimizing Chunking Process

Short description:

Chunking in a good way involves considering performance metrics that influence how chunks are formed. Understanding chunk groups and metrics like download size and request count per chunk group are crucial for optimizing performance.

And how to do chunking in a good way? So yeah. One thing is you can look at metrics. So most often, we care about the performance metrics. So these metrics basically influence how we chunk up stuff. And before we're looking into the metrics, we want to look into another term that is chunk groups. And I say chunk groups are basically a set of chunks that are loaded together that could be on an initial page load, you load these 10 chunks in script tags.

And that's an initial load chunk group. But it's also like other types of chunk groups, like on a dynamic import, there's an async loading chunk group where you load these chunks together as a group. Or a navigation between two pages is also like a chunk group. And we really want to look at a few metrics. One metric is the download size. And with download size, I don't mean bundle size because people often see bundle size as this is the size of the folder that the bundler, the output folder the bundler produces. But the total size of that folder, that really matters.

It might matter for compile time of your application, but it doesn't matter for the user perceived performance. What really matters is the download size per chunk group. These initial page load has whatever bytes downloaded or these on-demand loading of whatever bytes downloaded or this navigation has that much bytes downloaded. So, we really, really want to look at these metrics on a sense of per chunk group. And similar for the second metric, which is request count. Request count is obviously not good if you do a lot of requests because every request has an overhead.

QnA

Available in other languages:

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

The Future of Performance Tooling
JSNation 2022JSNation 2022
21 min
The Future of Performance Tooling
Top Content
Today's Talk discusses the future of performance tooling, focusing on user-centric, actionable, and contextual approaches. The introduction highlights Adi Osmani's expertise in performance tools and his passion for DevTools features. The Talk explores the integration of user flows into DevTools and Lighthouse, enabling performance measurement and optimization. It also showcases the import/export feature for user flows and the collaboration potential with Lighthouse. The Talk further delves into the use of flows with other tools like web page test and Cypress, offering cross-browser testing capabilities. The actionable aspect emphasizes the importance of metrics like Interaction to Next Paint and Total Blocking Time, as well as the improvements in Lighthouse and performance debugging tools. Lastly, the Talk emphasizes the iterative nature of performance improvement and the user-centric, actionable, and contextual future of performance tooling.
No REST for Cap'n Web
Node Congress 2026Node Congress 2026
23 min
No REST for Cap'n Web
Top Content
Kenton Varda advocates for using CapnWeb, an RPC protocol, over REST for web APIs, emphasizing benefits for humans and AI agents. CapnWeb simplifies client-server communications by treating them as function calls. TypeScript type checking ensures method accuracy in CapnWeb across JavaScript runtimes. Stubs in CapnWeb allow method calls to execute on remote objects and simulate all possible method names for remote calls. Converting REST APIs to CapnWeb streamlines code and improves API calls. CapnWeb enhances API functionality with object-specific RPC sessions and promises pipelining for multilevel API optimization. AI agent security challenges are addressed with sandboxing and token protection in CapnWeb. CapnWeb capabilities for AI agents include passing restricted CapnWeb stubs and exploring capability-based security with CapnProto.
Rome, a Modern Toolchain!
JSNation 2023JSNation 2023
31 min
Rome, a Modern Toolchain!
Top Content
Rome is a toolchain built in Rust that aims to replace multiple tools and provide high-quality diagnostics for code maintenance. It simplifies tool interactions by performing all operations once, generating a shared structure for all tools. Rome offers a customizable format experience with a stable formatter and a linter with over 150 rules. It integrates with VCS and VLSP, supports error-resilient parsing, and has exciting plans for the future, including the ability to create JavaScript plugins. Rome aims to be a top-notch toolchain and welcomes community input to improve its work.
Conquering Complexity: Refactoring JavaScript Projects
JSNation 2024JSNation 2024
21 min
Conquering Complexity: Refactoring JavaScript Projects
Top Content
Today's Talk explores the complexity in code and its impact. It discusses different methods of measuring complexity, such as cyclomatic complexity and cognitive complexity. The importance of understanding and conquering complexity is emphasized, with a demo showcasing complexity in a codebase. The Talk also delves into the need for change and the role of refactoring in dealing with complexity. Tips and techniques for refactoring are shared, including the use of language features and tools to simplify code. Overall, the Talk provides insights into managing and reducing complexity in software development.
Improving Developer Happiness with AI
React Summit 2023React Summit 2023
29 min
Improving Developer Happiness with AI
Top Content
GitHub Copilot is an auto-completion tool that provides suggestions based on context. Research has shown that developers using Copilot feel less frustrated, spend less time searching externally, and experience less mental effort on repetitive tasks. Copilot can generate code for various tasks, including adding modals, testing, and refactoring. It is a useful tool for improving productivity and saving time, especially for junior developers and those working in unfamiliar domains. Security concerns have been addressed with optional data sharing and different versions for individuals and businesses.
Automate the Browser With Workers Browser Rendering API
JSNation 2024JSNation 2024
20 min
Automate the Browser With Workers Browser Rendering API
The Talk discusses browser automation using the Worker's Browser Rendering API, which allows tasks like navigating websites, taking screenshots, and creating PDFs. Cloudflare integrated Puppeteer with their workers to automate browser tasks, and their browser rendering API combines remote browser isolation with Puppeteer. Use cases for the API include taking screenshots, generating PDFs, automating web applications, and gathering performance metrics. The Talk also covers extending sessions and performance metrics using Durable Objects. Thank you for attending!

Workshops on related topic

Pragmatic 101 on Custom JS Tooling for Your Project
JSNation US 2025JSNation US 2025
122 min
Pragmatic 101 on Custom JS Tooling for Your Project
Featured Workshop
Will Klein
Will Klein
Let’s demystify the secrets of modern JavaScript tooling. In this workshop, you will learn how linters, compilers, and code transforms work. You will take your first steps building your own developer tools, writing an ESLint rule, a compiler plugin, and a code transformation. Learn these skills to help your team and deepen your understanding of computer languages.Workshop Plan:A preview of how ASTs can be usedA brief walkthrough of how compilers workAn intro to working with an ASTThe secret to making thousands of changes in secondsHow to apply this skill
Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
JSNation 2023JSNation 2023
44 min
Solve 100% Of Your Errors: How to Root Cause Issues Faster With Session Replay
WorkshopFree
Ryan Albrecht
Ryan Albrecht
You know that annoying bug? The one that doesn’t show up locally? And no matter how many times you try to recreate the environment you can’t reproduce it? You’ve gone through the breadcrumbs, read through the stack trace, and are now playing detective to piece together support tickets to make sure it’s real.
Join Sentry developer Ryan Albrecht in this talk to learn how developers can use Session Replay - a tool that provides video-like reproductions of user interactions - to identify, reproduce, and resolve errors and performance issues faster (without rolling your head on your keyboard).