From the course: Learning webpack 4

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

What is code splitting?

What is code splitting?

From the course: Learning webpack 4

Start my 1-month free trial

What is code splitting?

- [Instructor] Throughout these videos, we've discussed how Webpack aims to optimize our code for performance and for developer ergonomics. By inlining CSS in the images, we can make our code faster. With the Webpack config, we can automate processes like transpiling. Now that we understand the basics, there may be situations where we want to use code splitting. Code splitting allows you to break up your code into different bundles. This can be done using multiple entry points. For example, if I have an application that has an About us and a Contact us page, we can tell Webpack to create bundles for each of these, and then only the resources necessary for the page will be loaded. This reduces the size of the request and if somebody visits the site and only goes to the About page, they won't load the Contact us information. Additionally, we can use Webpack to create bundles for shared code and for vendor code.

Contents