# Optimising BBC Online's Code Splitting Strategy

DevFeed: [Optimising BBC Online's Code Splitting Strategy](<https://devfeed.tech/articles/optimising-bbc-online-s-code-splitting-strategy-19174.md>)

Original publisher: [Read original article](<https://medium.com/bbc-product-technology/optimising-bbc-onlines-code-splitting-strategy-eb17172dea44?source=rss----ccd524e1760a---4>)

Author: Matt Williams

Published: 2022-05-30T15:21:09Z

Content type: article

Language: en

Sources: [BBC](<https://devfeed.tech/sources/bbc.md>)

Topics: [performance-optimization](<https://devfeed.tech/topics/performance-optimization.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Website](<https://devfeed.tech/topics/website.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [bbc](<https://devfeed.tech/tags/bbc.md>), [code-splitting](<https://devfeed.tech/tags/code-splitting.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [performance](<https://devfeed.tech/tags/performance.md>), [react](<https://devfeed.tech/tags/react.md>), [strategy](<https://devfeed.tech/tags/strategy.md>), [webpack](<https://devfeed.tech/tags/webpack.md>)

## AI overview

BBC Online reduced JavaScript download size and blocking time by splitting oversized shared bundles according to actual use. Separate async bundles for games-atlas, @optimizely, and date-fns trimmed about 80 KB gzipped (44%) from defaultVendors; component bundles used size thresholds and priority rules so large components load only where needed while smaller ones remain in website. After three weeks in production, JavaScript requests rose about 21%, but downloaded size fell 14% on average; Total Blocking Time fell 27% and Time to Interactive 6%. A heavily customized page saw 43% more requests but 15% less data, with blocking time down 31% and interactive time down 14%. The team expects to revisit the strategy as the platform grows.

## Source excerpt

Photo by Sen on Unsplash Modern JavaScript websites are the result of complex code bases, and the code base which powers BBC Online is no exception. There are many dependencies and frameworks that we rely upon in order to provide the functionality that our end-users expect, as well as code written in-house to cater to the needs of our website and its users; being able to click a button to follow a topic, search for content and play videos all require JavaScript code to be run by the browser. For a website as large and with as many seemingly disparate needs as the BBC's various pages, the amount of code required can grow exponentially. The code needed to render a news article - with images, social media embeds, videos and onward journeys - has only small elements of commonality with the code required to power complex sports data tables - with team badges, functionality to hide or show columns based on the screen width of the user's device, display a team's form, or provide live in-page updates for events that are happening live. As such, it has long been the practice of the JavaScript community to implement code splitting. Rather than providing all of our JavaScript and dependencies into a single large file to be downloaded by the user, we can split our code into separate files. This can provide advantages on two fronts; downloading multiple smaller files can be more efficient when devices can start those downloads in parallel (though going too far and downloading too many small files can cause problems itself!), and the way that we choose to split our files can mean that some only need to be downloaded on certain pages. It is this second benefit which can be most powerful; if you have a large piece of code on your site that is only needed for a single page, then forcing users to download that code on every page is wasteful, and can cause problems for users who might have limits on the amount of data they can download on their network. We have been using code splitti