Skip to main content

Chrome Local Overrides: Run Core Web Vitals Experiments

November 22, 2022 · Updated on · 6 min read
Matt Zeunert

Many site speed testing tools provide recommendations to make your website faster. But it can be hard to tell whether these recommendations will work and how big the impact will be.

To estimate how much an optimization will help you need to try it out on your website. But deploying a new change to a staging server can be slow.

The local overrides feature in Chrome DevTools offers a solution. It allows you to make changes to your website locally and then measure how they impact performance.

This article explains how local overrides work and how they can be used to test Core Web Vitals optimizations.

Screenshot showing DevTools local overrides

What are local overrides in Chrome DevTools?

Local overrides let you override server responses with file content saved locally on your computer. Instead of making a network request for a resource Chrome will serve it from a folder on your hard drive.

This lets you do a range of things:

  • Experiment with content changes on any website
  • Try out new CSS styles on any website
  • See how fast your website renders with certain render blocking files removed (to optimize Largest Contentful Paint)
  • Check if layout shift fixes are working correctly (to optimize Cumulative Layout Shift)

How to enable local overrides in DevTools

It takes a few steps to run your first experiment, but it’s easier after the initial setup:

  1. Open Chrome DevTools (by right-clicking the page and clicking Inspect)
  2. Switch to the Sources tab
  3. In the sidebar, select Overrides

Finding local overrides in Chrome DevTools

  1. In the sidebar Overrides tab, click Select folder for overrides (this is a folder on your computer where any custom HTML/CSS/... will be stored.)
  2. When you get the DevTools requests full access to the folder click Allow

Selecting a local folder for override contents

  1. Switch to the Page tab in the sidebar
  2. Right-click the file you want to override and click Save for overrides

Saving a file for local overrides

  1. The file now has a purple icon indicating that it’s served locally
  2. Click the file to edit it – in this example we just added a new style tag to the HTML
  3. Use Cmd+S (Mac) or Ctrl+S (Windows) to save your changes
  4. Reload the page to see the impact of the local overrides

GitHub homepage using red text after adding new style tag

Testing a Largest Contentful Paint optimization

Changing the text color is fun, but we want to optimize Core Web Vitals.

You can collect a performance profile using DevTools. If I go to the GitHub homepage with Slow 3G throttling enabled it takes about 4.8 seconds before the Largest Contentful Paint milestone is reached.

Baseline LCP test result

GitHub loads a number of JavaScript files that aren’t important for the initial render. Let’s try commenting them out.

Script tags commented out in Chrome DevTools

Now the page renders in just 3.0 seconds.

Lower LCP after running experiment

Of course if we wanted to do this in production we’d need to think more about whether we still need to load those scripts and when they should be loaded. But at least we have a rough idea of how big the performance impact of removing the scripts would be.

You can try out a range of LCP optimizations with local overrides, for example:

Run page speed experiments on DebugBear

DebugBear provides detailed page speed recommendations and lets you try out fixes through local overrides using the experiments feature.

When viewing a test result expand a recommendation with a beaker icon and click on "Run Experiment" to preview an HTML change and measure its performance impact.

Performance recommendation

Once the experiment has run you can see how your metrics have improved and what that means for user experience.

Here the Largest Contentful Paint metric improves from 2.0 seconds to just 1.1 seconds. The main image on the page appears much earlier in the page load process.

DebugBear experiment result

Testing a Cumulative Layout Shift optimization

Similarly, we can use local overrides to see if CLS fixes are working.

Let’s look at this layout shift on the Iceland homepage. Once the slider appears all other content shifts down on the page.

Layout shift in DebugBear test result

We can fix that by adding a CSS min-height to the slider.

<style>
.carousel {
min-height: 288px;
}
</style>

The carousel now shows an empty area until the slider content loads. When it does load no page elements are pushed down the page and the layout remains stable.

DevTools performance profile showing an early page snapshot with empty space

Overriding Response Headers

Response header overrides are an experimental DevTools feature that allows you to substitute response headers in addition to the response body.

To enable this feature, first enter the DevTools settings.

DevTools settings gear icon in the top right corner

Then select the Experiments tab and check the Local overrides for response headers box.

DevTools Experiments menu

In the DevTools Network tab you can now right click a request and select Create response header override.

Create response header override in DevTools Network tab

Then you can click Add header override to create your custom header. In this example we add a link preload header to load a specific JavaScript file early.

Adding a response header override in DevTools

After reloading the page we can see that this header is returned with the document response and the file is preloaded.

The new link preload header in the Network tab

Limitations of local overrides

Local overrides allow you to change server responses locally, but testing in DevTools doesn’t always produce reliable data.

This is because DevTools throttling doesn’t accurately model network connections and resource priorities. So the results you see in DevTools may not always translate directly to the impact of your change on real users.

Monitor website performance

DebugBear lets you track performance, identify optimizations, and try out possible fixes. It's a comprehensive solution for web performance monitoring and optimization.

Page speed monitoring dashboard

Illustration of website monitoringIllustration of website monitoring

Monitor Page Speed & Core Web Vitals

DebugBear monitoring includes:

  • In-depth Page Speed Reports
  • Automated Recommendations
  • Real User Analytics Data

Get a monthly email with page speed tips