Find costly requests, ship smaller production assets and measure what actually changes.
A fast page delivers its main content quickly and responds promptly when a visitor starts using it. Saving bytes helps, but the order of requests and the work those requests trigger matter too. Start with a page that represents a real visit. Identify which image or block of text appears as the main content, which interaction the visitor is likely to try first and which parts of the page can arrive later. A measurement based on that path gives you a reason to change one resource before another.
Measure a cold visit before editing files
Open the browser’s network panel, disable its cache for the test and choose a repeatable throttling setting. Reload the URL and look for the document, its stylesheet, the largest above-the-fold image and scripts. Record their order, transfer sizes and completion times. Export a record or take notes before editing. Test a warm reload separately with caches enabled. If you mix the two results, it is easy to attribute a fast cached response to a code change.
A performance recording adds context to the request list. Look for the largest visible content paint, unexpected layout shifts and long tasks around the first click. The Core Web Vitals measure the speed of displaying the largest visible content, responsiveness across interactions and visual stability. A lab run is useful for isolating a cause. Real-user measurements, where you have enough traffic to collect them, describe devices and connections that your test machine cannot represent. Repeat lab runs using the same conditions and inspect the range of results.
Minify production files and check compression
Minifiers remove or shorten source that the browser can interpret without the original formatting. Keep readable source in version control and generate minified assets during a reproducible build. Use a JavaScript-aware minifier which understands your syntax and target browsers. A tool that removes whitespace blindly can affect strings or change how a program parses. In HTML, whitespace can also matter in preformatted text and between inline elements. Compare rendered output and run existing functional tests whenever a build step first touches a file type.
Compression happens during transfer. A server can send compressed HTML, CSS or JavaScript when the browser supports the encoding it offers. Inspect the response headers for the content encoding and compare transferred size with the resource size shown in developer tools. Recheck on the public URL, where a reverse proxy or CDN might behave differently from local hosting. Already compressed images depend mainly on their image encoding and dimensions, so moving them through a general text compressor rarely brings comparable savings.
Use the HTML minifier, CSS minifier and JavaScript minifier to experiment with standalone files. Keep a copy of the readable originals so you can compare the result or change a setting. The formatting tools help inspect pasted code when you need to identify the markup or declarations still present after a build.
Prioritise resources the first view needs
The first stylesheet is often needed to draw readable content in the intended layout. Keep essential styles available early and remove rules the page genuinely no longer uses. Coverage reports help you find candidates, but exercise menus, inserted content and alternate viewport widths before deleting rules. A line unused during a single navigation might still be required when a user opens a dialog. Large libraries used by only one feature can often be loaded on the pages where that feature exists.
A classic script in the document head can stop the HTML parser while it loads and runs. Use deferred loading for scripts which need parsed elements and depend on an expected order. Use asynchronous loading only for scripts designed to work independently. Deferring a script does not make its execution free. If the recording still shows a long task after it downloads, find the feature responsible and see whether you can do less work before a visitor actually needs it.
Try reserving space for a delayed image
Preview this small example and compare the heading’s position before and after the drawing loads. Its dimensions make the image’s aspect ratio available before the data arrives. On a real site, supply the representative image’s intrinsic dimensions and let CSS size it to the available width. The inline drawing lets you try the technique without a third-party request.
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Stable image layout</title>
<style>
body { margin: 1.5rem auto; padding: 0 1rem; max-width: 36rem; font: 1rem/1.5 system-ui; }
img { display: block; width: 100%; height: auto; background: #dbeafe; border-radius: .6rem; }
</style>
<h1>Give a delayed image room</h1>
<button type="button" id="delayed">Load drawing after a delay</button>
<img id="example" width="640" height="240" alt="Sun rising above a blue ridge">
<p id="status" role="status">The space is reserved.</p>
<script>
const button = document.querySelector('#delayed');
const image = document.querySelector('#example');
const status = document.querySelector('#status');
const drawing = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 240"><rect width="640" height="240" fill="#bae6fd"/><circle cx="420" cy="75" r="34" fill="#fde047"/><path d="M0 240 240 81 380 180 535 120 640 240Z" fill="#2563a4"/></svg>';
button.addEventListener('click', () => {
status.textContent = 'Waiting for the drawing…';
button.disabled = true;
setTimeout(() => {
image.src = 'data:image/svg+xml,' + encodeURIComponent(drawing);
status.textContent = 'Drawing loaded. Its space stayed the same.';
}, 650);
});
</script>
</html>
Try it in the HTML editor
Send images appropriate to the layout
An asset with twice the necessary pixel width can cost extra bytes and decoding time. Determine the widths at which a given image is displayed and prepare a small set of useful sizes. Use responsive image candidates so the browser can account for the layout and device pixel density. Give a hero image a discoverable source in HTML and avoid delaying it with lazy loading. Images well below the initial view are better candidates for lazy loading. Compare visually similar exports in the WebP image converter and keep a suitable source or fallback where needed.
Very large displays and fine diagrams still deserve enough resolution to read. Test text inside screenshots at their actual CSS size, including zoom. If a screenshot becomes illegible after compression, try a sharper export or move essential text into HTML. Reducing the cost of an asset is useful only if it still serves the reader’s purpose. Compare several representative assets before setting a quality default for a batch.
Set cache instructions around your release process
Versioned static assets can have long cache lifetimes because a content change creates a different URL. Deploy those assets before the HTML that refers to them, and keep old versions available as long as cached documents may still use them. Use different instructions for HTML that needs to reflect content changes promptly. Revalidation lets a browser or cache check freshness, and may avoid sending the full body when nothing changed. Inspect cache headers and status codes on the final host instead of assuming development settings reached production.
After deployment, try a first visit and a repeat visit. Then navigate through the site with a tab opened before the update, especially when releasing scripts that load other files on demand. A chunk removed too early can cause a delayed error even though fresh visits work. Run relevant interactions with the cache both enabled and disabled, and verify that downloads, keyboard navigation and mobile layouts still work. Compare the same request and performance measurements to the baseline. Use web.dev’s Web Vitals guidance to interpret the results alongside field data.
Find work that happens after the first paint
A page can look complete while a script keeps the main thread busy. Record an interaction that opens a menu, filters a list or runs a preview. If the browser spends a long time in one event handler, open the relevant entry in the recording and identify what it calls. When a list contains hundreds of entries, processing every item after every keystroke may be unnecessary. Start by reducing redundant work, then check that the visible result still updates soon enough for a reader to understand what happened.
Third-party resources need their own test. Compare two recordings with and without the integration on a test page and check which requests and script activity it adds. An embed that is only useful after a click can often start from a plain link or a lightweight placeholder. If an important interaction depends on an external service, try a slow or unavailable response and confirm that the main site stays usable. This helps catch a regression that page weight by itself cannot explain.
Save the test URL, browser settings and build identifier alongside the before and after results. Another person should be able to recreate the comparison after the next change. A short record is enough if it explains which bottleneck you addressed and which user action you retested.