How to Improve Website Performance and Reduce Costs
Measure real user experience, find the page-level bottleneck, and choose performance fixes that also control hosting and bandwidth costs.
To improve website performance and reduce costs, measure real-user experience and actual infrastructure use, identify the page-level bottleneck, make the smallest change likely to address it, then measure user outcomes and bills again. Start with representative pages and devices; do not scale up, migrate hosts, or rewrite an application before evidence points to a need.
Use field data to understand what visitors experience and lab diagnostics to reproduce and investigate problems. For slow loading, trace the Largest Contentful Paint (LCP) element and separate server response, resource discovery, download, and render time. Then prioritize right-sized images, early discovery of critical resources, less render-blocking work, appropriate caching, and infrastructure changes supported by observed traffic.
1. Set targets and establish a baseline
Google’s good-experience Core Web Vitals targets are LCP at 2.5 seconds or less, Interaction to Next Paint (INP) below 200 milliseconds, and Cumulative Layout Shift (CLS) below 0.1. Treat these as targets for user experience, not guarantees of rankings, conversions, or savings. Core Web Vitals are part of page experience; a good report does not guarantee a top search position. Google Search Central: Core Web Vitals.
Collect a baseline before changing code or infrastructure:
- Choose representative page types: for example, a landing page, article, product page, and a page with a demanding interaction.
- Review the Search Console Core Web Vitals report for site-level patterns.
- Inspect individual URLs in PageSpeed Insights. Where available, compare field information with its Lighthouse lab diagnostics.
- Record the affected URL or template, device category, field metric, lab observations, error signals, traffic, infrastructure resource use, and actual bills over a comparable period.
- Repeat measurements after a change under comparable conditions. Keep a record of what changed so improvements or regressions have an explainable cause.
Field data reflects real devices, networks, and interactions. Lab tests are useful for repeatable diagnosis, but a lab run does not reproduce every user’s conditions or interaction. Lighthouse does not measure INP from real user interactions; Total Blocking Time (TBT) can help diagnose main-thread blocking in a lab, but it is not INP. Compare page-level field data with diagnostics before deciding what to fix. web.dev: Web Vitals.
2. Find the bottleneck before choosing a fix
A poor metric is a symptom. Identify which part of the page or request path is responsible before spending engineering time or money.
For slow LCP, trace the largest visible element
Use PageSpeed Insights and browser diagnostics to identify the LCP element and examine its timing breakdown:
- Time to first byte (TTFB): A slow start can result from redirects, distance, network conditions, slow application work, or cache misses.
- Resource load delay: If the LCP image or other resource starts late, it may not be discoverable in the initial HTML. Client-side rendering, late CSS background discovery, or JavaScript that inserts the content can delay the request.
- Resource load duration: A large file, an unnecessarily large image, or limited bandwidth can make transfer take longer.
- Element render delay: The resource may have arrived, but CSS, JavaScript, fonts, or other rendering work can prevent it from appearing promptly.
web.dev offers approximate LCP breakdown guidance—TTFB around 40%, resource load delay under 10%, resource load duration around 40%, and element render delay under 10%. These are diagnostic guidelines, not universal pass/fail targets or fixed time budgets. web.dev: Optimize LCP.
For slow interactions, examine field INP and lab clues
Use field INP to understand interaction responsiveness across real visits. If it is poor, investigate long JavaScript tasks, event handlers, and expensive rendering work. Lab TBT can help expose main-thread blocking during a reproducible load, but it cannot stand in for the range of interactions represented by field INP.
For layout instability, identify what moves
Inspect the elements that shift and the moments they move. Reserve space for images, ads, embeds, and other content whose dimensions are not immediately known. Check whether fonts or asynchronously inserted content change the layout after the page has rendered.
3. Fix high-impact page weight and rendering problems
Make changes that address the diagnosed cause, then remeasure. Avoid applying every optimization to every route.
Right-size and optimize important images
Serve dimensions appropriate to the rendered slot and the visitor’s viewport. Choose an efficient web image format and compression level that preserves the required visual quality. Provide responsive variants where appropriate, and avoid downloading a desktop-sized hero image for a small mobile slot. Lazy-load offscreen images, but make the above-the-fold LCP image available early rather than delaying it behind lazy loading.
Images are often worth investigating: web.dev’s business guidance cites HTTP Archive data indicating that approximately 80% of web pages have an image as the LCP element. The source excerpt does not establish a data year, so this is context rather than a current measurement for your site. For images already in your workflow, web.dev names TinyJPG as an example of a service that removes unnecessary image data; choose a processing method based on your own quality, workflow, and cost needs. web.dev: Optimize Core Web Vitals for business decision makers.
Make critical content and resources discoverable early
Keep important page content present in initial HTML when practical. If the browser only learns about the main image after executing JavaScript, it cannot begin fetching that image as early. Remove unnecessary redirects and avoid adding resource chains that delay critical CSS, fonts, or images. Preload only resources that are truly critical; indiscriminate preloading can compete for bandwidth with other important requests.
Reduce blocking and unused code carefully
Audit render-blocking CSS and JavaScript. Remove code that is not needed on the route, split bundles where that reduces work without creating excessive request overhead, and defer noncritical scripts. Use Chrome DevTools Coverage to identify unused CSS and JavaScript on a page. Verify changes against the page’s actual behavior: code that appears unused in one capture may be needed after a user interaction. web.dev: Reduce unused CSS.
Be deliberate with video and carousels
Large video files and image carousels can consume bandwidth and compete with the content visitors came to see. Defer nonessential media, use suitable poster images, and avoid loading multiple large slides before they are needed. Measure whether the change improves the relevant user experience and whether it affects engagement or functionality.
4. Use caching and delivery to avoid repeat work
Caching can reduce repeated downloads, application work, database queries, and origin load. Choose the layer that matches what is being reused; each layer has different freshness and invalidation requirements.
| Layer | Useful for | Tradeoff to manage |
|---|---|---|
| Browser cache | Static files a visitor may reuse on later visits. | Long-lived files need versioned names or another reliable way to avoid stale content. |
| Server or application cache | Repeated computation or responses that can safely be reused. | Dynamic or personalized responses must not be shared incorrectly; define invalidation and freshness rules. |
| CDN cache | Delivering cacheable resources nearer visitors and reducing repeated origin traffic. | A CDN does not automatically fix JavaScript execution or a slow dynamic origin. Cache rules and purge behavior need monitoring. |
| Database or query-result cache | Repeated expensive reads where results remain valid for an understood period. | Stale results and invalidation complexity can outweigh the savings for frequently changing data. |
| Service worker | App-controlled reuse and offline or repeat-visit behavior. | More lifecycle and cache-versioning logic is required; test upgrades and invalidation. |
Version static assets so a long cache lifetime can coexist with updated content. Give dynamic responses a policy that reflects their freshness and privacy needs instead of applying one blanket rule. Compression and minification can reduce transferred bytes, but verify that compression is enabled for the relevant responses and that added processing costs are justified.
Image optimization can run in your build, on your own origin, or through a service or CDN. A third-party image domain can add connection overhead; web.dev says same-origin delivery is generally preferable when feasible and notes some CDNs can proxy through the origin. Consider the full request path and your operational constraints. web.dev: Optimize LCP.
5. Match infrastructure to measured demand
Hosting cost is not an optimization target in isolation. Compare real bills and resource use with field performance, errors, and reliability. A smaller server that causes timeouts or slow responses may cost more in lost reliability than it saves in infrastructure. Conversely, provisioning for an assumed peak that rarely occurs may leave room to right-size or use scaling that follows observed demand.
- Review traffic patterns, CPU and memory use, storage, bandwidth, cache hit behavior, and error rates over representative periods.
- Scale up or add capacity when measurements show resource saturation or reliability problems; optimize application or database work first when that is the cause.
- Consider autoscaling and load balancing for changing demand, while accounting for their configuration and monitoring needs.
- Compare managed hosting’s operational support and upkeep with self-managed hosting’s control and flexibility. Compare total cost, including engineering and maintenance, rather than headline infrastructure price alone.
- Use CDN delivery when geography, static asset volume, or origin load makes it useful. A CDN is not a substitute for diagnosing application response time or client-side work.
There is no universal savings percentage: costs depend on architecture, traffic, provider pricing, and implementation. Google’s hosting guidance emphasizes planning, monitoring, and flexibility as traffic patterns change. Google for Developers: Hosting optimizations for content-driven web apps.
6. Migrate hosting only with a validation plan
Moving providers or platforms can change response time and cost, but it also creates operational risk. Treat it as a measured migration:
- Copy the application, data, configuration, and required background tasks to the new environment.
- Test pages, forms, authentication, payments, APIs, scheduled work, redirects, and other important user flows in the new environment.
- Check crawler access, canonical URLs, robots rules, certificates, and redirects so search engines can reach the intended pages.
- Compare response time, errors, resource use, and expected costs under realistic traffic. Exercise capacity limits where practical.
- Change DNS only after the new path is validated. Monitor traffic, errors, and performance after the change.
- Retain the old setup until the new environment is verified and the rollback window has passed; retire it after the service is correct.
See Google’s hosting optimization guidance and Google Search Central’s site move guidance.
7. Run a change-and-measure loop
- Measure: Gather field metrics for representative page types and devices, plus lab diagnostics and cost/resource data.
- Choose one bottleneck: State the evidence and the expected effect. For example, “The hero image is the LCP element and starts downloading late because it is inserted after client-side rendering.”
- Make the smallest relevant change: Expose the image earlier or right-size it, depending on the measured cause.
- Check quality and reliability: Confirm the page still works, images remain clear, and error rates or other metrics have not regressed.
- Remeasure over a comparable period: Compare field experience and actual bills, not only a single synthetic score.
- Keep, adjust, or revert: Keep a change when the outcome supports its cost and complexity. Revisit the diagnosis if it did not improve the expected bottleneck.
This process helps distinguish a user-facing improvement from a lower lab score or a lower bill that came with slower responses. A strong report is useful evidence, but business owners must decide how much to invest and what return justifies it. web.dev: Optimize Core Web Vitals for business decision makers.
8. Capture pages consistently while diagnosing visual issues
When an issue is visual—such as a layout shift, missing image, cookie overlay, or responsive breakpoint—consistent screenshots can help compare before and after states. Capture the same URL at the same viewport and state; screenshots complement field metrics and browser diagnostics, but do not replace them.
Do it yourself with a browser
Here is a runnable Playwright example in JavaScript. It captures a full-page PNG at a fixed viewport. Install Playwright and its Chromium browser, save this as capture.mjs, then run it with Node.js:
npm install playwright
npx playwright install chromium
// capture.mjs
import { chromium } from 'playwright';
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1365, height: 900 } });
try {
await page.goto('https://example.com', { waitUntil: 'networkidle', timeout: 60000 });
await page.screenshot({ path: 'page.png', fullPage: true });
} finally {
await browser.close();
}
For a quick one-off, browser DevTools can capture a screenshot without adding a script. For repeatable comparisons, script the viewport, browser, wait condition, and page state so runs are comparable. Replace networkidle if the page keeps long-lived network connections; wait for a meaningful selector or use a deliberate delay instead. See Playwright screenshot documentation.
9. Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request returns a PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie and consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and the response identifies page verdict and billing status in headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. See ScreenshotNeo and the API documentation.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
Cookie banners, popups, and chat widgets are removed before the shot. Bot checks, blank pages, and failed loads are never billed. An MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for 1,000 free screenshots a month, no card required.
10. Troubleshoot common performance problems
| Symptom | Likely cause | What to check or change |
|---|---|---|
| LCP remains slow after image compression | The image request starts late, the server response is slow, or rendering is delayed. | Inspect TTFB, resource load delay, transfer duration, and element render delay separately. Confirm the LCP resource is discoverable early and not blocked by CSS or JavaScript. |
| Lab score improves, field experience does not | The lab conditions or tested route do not represent visitors’ devices, networks, or interactions; field data may also take time to reflect a release. | Compare the same page type and device category in field data. Use lab runs to investigate, not as a substitute for user measurements. |
| TBT looks good but INP is poor | Lab load behavior does not cover the real interactions that drive field INP. | Investigate the interactions and pages represented in field data. Do not treat TBT as an INP measurement. |
| Images look stale after deployment | Long-lived cached files kept the old asset. | Version or fingerprint static asset filenames and verify cache headers and invalidation behavior. |
| Pages become stale or show another user’s data | A shared cache policy is too broad for dynamic or personalized responses. | Review cache keys, response headers, and which responses may safely be reused. Exclude personalized content from shared caching where appropriate. |
| CDN is enabled but pages still feel slow | The slow portion may be dynamic origin work, JavaScript execution, or render-blocking code rather than static delivery. | Measure cache hits, TTFB, and client rendering separately; fix the layer shown by evidence. |
| Performance degrades during traffic peaks | Capacity, database work, or a dependency may be saturated. | Correlate response time and errors with resource metrics and traffic. Optimize the constrained work or add capacity based on observed demand. |
| Hosting bill rises after adding a cache or CDN | New service charges, low cache hit rates, invalidation patterns, or uncached dynamic requests may offset savings. | Review itemized bills, request volume, cache behavior, and origin traffic over comparable periods. Tune or remove a layer that does not justify its cost. |
| Migration lowers the bill but introduces failures | Environment configuration, background work, DNS, certificates, crawler access, or capacity may differ. | Validate user flows and crawler access before migration, monitor after DNS changes, and keep a rollback path until verified. |
11. Frequently asked questions
How can I make my website load faster?
Start with field measurements for the affected pages, then diagnose whether delay comes from the server response, late resource discovery, large transfers, or rendering. Make a targeted change and remeasure.
How do I reduce website hosting costs?
Review actual traffic, resource use, cache behavior, and bills first. Reduce repeated work and unnecessary transfer where measurements support it, then right-size capacity while watching response times and errors.
What should I fix first to improve Core Web Vitals?
Fix the largest diagnosed bottleneck on the page type affecting real users. For LCP, trace the LCP element and its timing breakdown; for INP and CLS, use field data to find the affected interactions and shifting content.
Does a good Core Web Vitals report guarantee better search rankings?
No. Google describes Core Web Vitals as part of page experience, and a good report does not guarantee top rankings. Use the metrics as user-experience targets.
Should I optimize until Lighthouse gives a perfect score?
No single lab score represents every user or business outcome. Use repeatable lab diagnostics to locate issues, then confirm meaningful changes with field experience, reliability, and cost data.
Will adding a CDN fix a slow site?
It can help deliver cacheable resources nearer visitors and reduce origin traffic. It will not automatically fix slow dynamic application work, JavaScript execution, or render delays.
For broader measurement guidance, see web.dev’s Web Vitals overview and Google’s Core Web Vitals documentation.


