Case study
How GOV.UK retired a shared JavaScript dependency
The Government Digital Service traced jQuery across publishing applications and measured the change in the pages people downloaded.
A dependency shared across applications
In August 2022, the Government Digital Service described removing jQuery from most of GOV.UK. The team counted at least 200 scripts that referenced the library, along with additional tests. Readers visiting largely static pages paid a download cost for that shared dependency. The homepage weighed approximately 246 kB, of which jQuery accounted for about 32 kB.
How the team finished the migration
Developers moved individual components over as opportunities arose and avoided introducing fresh dependencies on jQuery. Two applications still needed it. Those applications received their own copies, which allowed the shared dependency to come out and the rest of the site's pages to shed the download. The team's account puts the saving for most pages at roughly 32 kB per visit with an empty cache.
A lesson for a portfolio site
Begin with a single common route and record what a new reader actually downloads. A navigation toggle may account for only a few lines in your code while bringing a much larger library into every page. List the controls that use it, exercise them with a keyboard after each replacement, and repeat the measurement with a fresh browser cache. Report the affected routes alongside the byte saving so the number has a clear meaning.