PageSpeed optimization in seven steps
Each step is marked with who does it: you, or software at the web server.
- 1 Measure. Run a lab test and read the field data if the site has any. You
- 2 Fix server response time if it is slow. You
- 3 Optimize images: recompress, convert, resize, lazy-load, reserve their space. Server
- 4 Minify and combine CSS and JavaScript, then test critical CSS and script deferral. Server
- 5 Set long cache lifetimes on static resources and turn on compression. Server
- 6 Audit third-party scripts and long tasks. This is the INP work. You
- 7 Measure again. Field data needs up to 28 days to reflect the change. You
What PageSpeed optimization means in 2026
PageSpeed began as Google’s name for a family of tools: PageSpeed Insights, the PageSpeed modules for web servers, and the libraries they share. Google’s overview of the tools still describes the modules as software that rewrites and optimizes resources on an Apache or nginx server automatically. Today the phrase covers any work that improves what those tools measure, and it is often written as page speed optimization.
Two results are measured. The lab result is one Lighthouse run on emulated hardware, which gives the 0 to 100 Performance score. The field result is the Chrome User Experience Report: real Chrome users at the 75th percentile over the previous 28-day collection period, as the PageSpeed Insights documentation describes. The PageSpeed Insights page maps each audit to its fix, and the Core Web Vitals pages go through each metric.
| Metric | Good in the field | Poor in the field | Weight in the lab score |
|---|---|---|---|
| Largest Contentful Paint (LCP) | 2.5 s or less | over 4.0 s | 25% |
| Interaction to Next Paint (INP) | 200 ms or less | over 500 ms | 0 |
| Cumulative Layout Shift (CLS) | 0.1 or less | over 0.25 | 25% |
| First Contentful Paint (FCP) | 1.8 s or less | over 3.0 s | 10% |
| Total Blocking Time (TBT) | lab only | lab only | 30% |
| Speed Index | lab only | lab only | 10% |
LCP, INP and CLS are the Core Web Vitals, assessed at the 75th percentile of page loads. Sources: web.dev’s Core Web Vitals article, its account of how the thresholds were set, the Lighthouse scoring guide and the default configuration in the Lighthouse source.
INP replaced First Input Delay as a Core Web Vital on 12 March 2024. A Lighthouse page load has no user input, so it cannot measure INP. INP has a weight of 0 in the lab score, and Total Blocking Time is its lab proxy. Time to First Byte is not a Core Web Vital, but every other metric starts after it; web.dev suggests 0.8 seconds or less for most sites.
The optimizations, and which ones can be automated
Each row says whether a web server module can apply the optimization with no change to your application, links the mod_pagespeed filter that does it, and names what remains your job.
| Optimization | Server can automate it | mod_pagespeed filter | What stays in your code |
|---|---|---|---|
| Images | |||
| Recompress images and strip metadata Page weight, LCP | Yes | Checking logos and screenshots with text for quality. | |
| Serve WebP to browsers that accept it Page weight, LCP | Yes | A CDN in front must pass the Accept header and vary on it. | |
| Serve AVIF to browsers that accept it Page weight, LCP | Partly | Opting in, and the extra CPU that AVIF encoding takes. | |
| Resize images to the size they are shown at Page weight, LCP | Partly | Width and height in the markup. Art direction. | |
| Lazy-load images below the fold Initial page weight | Yes | Marking a critical image that detection misses. | |
| Reserve space for images CLS | Partly | Space for ads, embeds and script-inserted content. | |
| Fetch the LCP image first LCP | Partly | Background images set by a script. | |
| CSS | |||
| Minify CSS Page weight | Yes | Nothing. | |
| Cut stylesheet requests Request count, first paint | Yes | Nothing. | |
| Inline critical CSS and load the rest without blocking FCP, LCP | Partly | Testing it. Removing CSS that no page uses. | |
| Web fonts CLS, LCP | Partly | Which fonts, how many weights, subsetting and font-display. | |
| JavaScript | |||
| Minify JavaScript Page weight | Yes | Nothing. | |
| Cut script requests Request count | Yes | Nothing. | |
| Defer script execution FCP, Total Blocking Time | Partly | Testing every page type. Some scripts break. | |
| Ship less JavaScript and break up long tasks INP, Total Blocking Time | No | Your code | Code splitting, lighter frameworks, shorter event handlers. |
| Control third-party scripts INP, Total Blocking Time | No | Your code | Auditing tags and loading the rest late. |
| HTML and resource hints | |||
| Minify HTML Page weight | Yes | Nothing. | |
| Warm up connections to other origins Connection setup time | Yes | Reducing how many origins a page depends on. | |
| Preload stylesheets and scripts FCP, LCP | Partly | Font preloads and the choice of what is critical. | |
| Caching and compression | |||
| Long browser cache lifetimes with content-hashed URLs Repeat-visit load time | Yes | The cache policy of the HTML itself. | |
| Compress text responses with gzip or Brotli Page weight | Yes | Web server setting, not a filter | Turning it on once. |
| Application and back end | |||
| Generate the page faster TTFB, and every metric after it | No | Your code | Queries, application code, page caching, hosting capacity. |
The filter reference lists every filter with its risk rating, and filter selection explains which ones are on by default.
Images
rewrite_images
is on by default and keeps a result only when it is smaller than the original. AVIF, lazy
loading and added dimensions are opt-in. Resizing follows the width and
height in the markup: an image sized only by CSS keeps its original dimensions
unless you enable
resize_, which resizes to the size browsers report. Art direction, the choice of the LCP image and
the size of the files people upload stay manual.
CSS
Minifying, combining, flattening @import chains and inlining small files are on
by default.
prioritize_
is opt-in and rated “test first”. It learns which rules a page uses from
visitors’ browsers, so it takes effect after a few page loads, and it does not run on
Envoy. The font filter only inlines the Google Fonts stylesheet. No filter removes CSS that
your pages never use.
JavaScript
Minification is on by default and leaves identifiers alone.
defer_javascript
is opt-in, because it breaks scripts that call document.write or expect to run
during parsing. Nothing at the server can decide that a page needs less script or split a
long task into short ones. INP is decided here, in code you or your vendors wrote.
HTML and resource hints
None of these filters is on by default.
hint_
and
prioritize_
depend on reports from real visits and do nothing until they have them. Font preloads stay
manual.
Caching and compression
extend_cache
is on by default. A URL carries a hash of the file’s content and gets a one-year cache
lifetime, so a changed file is fetched again. It does not make HTML cacheable. Compression
with gzip or Brotli is a setting of the web server itself.
What no server module fixes
A module rewrites the bytes that leave your server. It does not change what your application does. These stay with you:
- Slow interactions (INP) and long tasks
- Event handlers, hydration and framework work run on the visitor’s main thread. Minifying and deferring scripts reduces the work at startup. It does not make a slow click handler fast. The INP guide covers the application-side fixes.
- Third-party scripts
- Analytics, tag managers, chat widgets and ads load from other origins and run their own code. By default a module leaves resources on other origins untouched, and no rewrite changes what a vendor’s script does once it runs.
- A slow back end
- When the application takes a second to build the page, the first byte is a second late. The fix is in queries, application code, page caching or capacity.
- Layout shifts from late content
- Missing image dimensions can be added at the server. Ads, embeds and anything else a script inserts above existing content need space reserved in your CSS.
- Heavy client-side frameworks
- A page that renders in the browser pays in script size and main-thread time. On pages it recognizes as hydrated, mod_pagespeed holds some filters back so the framework keeps working.
Build, plugin, CDN or server module: where to optimize
None is best in every case. A static site with a good build pipeline already has most of the table above. A site whose content is uploaded by editors, or a server that hosts several applications, gains most from a module or an edge service. A CDN also shortens the network path to the visitor, which no server module does; the two are often combined.
| Where | Code changes | Reach | Where it runs, what it costs |
|---|---|---|---|
| Build pipeline | Build configuration, and often templates. | Only what the build produces, not images that editors upload later. | Runs on the build machine. Costs build time and upkeep. |
| CMS plugin | None, though one plugin per job is common. | One CMS. Other applications on the server get nothing. | Runs in the application or at the vendor. Free to a subscription. |
| CDN or edge service | None, unless you adopt the provider’s image URLs. | Every site routed through the provider. | Runs on the provider’s network. Plan-based or metered. |
| Web server module | None. It rewrites responses as they leave the server. | Every application on that server, in any language. | Runs on your own server. The software is free; you pay in CPU and disk. |
The alternatives pages compare mod_pagespeed with specific plugins, CDNs and image services.
Automatic PageSpeed optimization at the web server
A server-side optimizer sits in the response path. It parses the HTML as the application produces it, optimizes the images, stylesheets and scripts the page refers to, and caches the results on the server. Each rewrite has a short deadline, 10 milliseconds by default. If the optimized file is not ready in time, that response keeps the original URL and later responses use the cached result. Source files on disk are never modified.
mod_pagespeed is open source under the Apache License 2.0, so the cost is in resources: CPU for the first optimization of each image (at most eight at once by default, and AVIF adds an extra decode and encode), disk for the cache, and a warm-up period while the cache fills. The examples gallery shows the original and the optimized output of individual filters on live pages, and How it works explains the mechanics.
PageSpeed optimization on nginx
Install the module from the signed package repository, then turn it on in a
server block. The default filters are active as soon as the module is on;
EnableFilters adds the opt-in ones.
pagespeed on;
pagespeed FileCachePath /var/cache/ngx_pagespeed;
pagespeed EnableFilters lazyload_images,insert_image_dimensions;
The nginx install steps cover the packages and the optimizer worker, a separate process that takes the heavy work off the web server.
PageSpeed optimization on Apache
The Apache package enables the module and its default pagespeed.conf, so the
default filters run after a restart. Add opt-in filters in that file. The
Apache install steps
have the commands.
ModPagespeed on
ModPagespeedEnableFilters lazyload_images,insert_image_dimensions
PageSpeed optimization on IIS
On IIS, mod_pagespeed runs as a native module installed from a signed MSI. A site is
optimized when its root holds a pagespeed.config file; the
IIS install guide
has the details. There is also an experimental
Envoy HTTP filter, built from source and not packaged.
WordPress, Magento and other applications
The module works below the application, so it needs no plugin, and every application on the server shares one configuration. The WordPress page covers that stack, and the Core Web Vitals hub links a guide per platform and metric.
Where the PageSpeed modules came from, and where they are now
mod_pagespeed started as an open-source Apache module developed at Google. Google’s documentation describes its core, the PageSpeed Optimization Libraries, as “a set of C++ classes that automatically optimize web pages and resources they use”. ngx_pagespeed brought the same core to nginx. The project entered the Apache Incubator on 30 September 2017, and the podling retired on 17 March 2023.
We-Amp B.V. helped build ngx_pagespeed, maintained mod_pagespeed and drove the project’s Apache incubation, and it develops mod_pagespeed today for Apache, nginx and IIS. The directive syntax and filter names are the ones the original modules used. The PSOL page and the maintenance status page have the details.
Check a page before you change anything
Measure first. Run a URL through the analyzer or through Google’s PageSpeed Insights tool. The analyzer calls Google’s public PageSpeed Insights API and marks which findings a server module addresses.
Open source under the Apache License 2.0 — free in development and in production.
Common questions
- What is PageSpeed optimization?
- PageSpeed optimization is the work of making web pages load, render and respond faster, judged by Lighthouse lab tests and Core Web Vitals field data. In practice it means smaller images, less render-blocking CSS and JavaScript, better caching, a faster server response and less main-thread work in the browser.
- Can PageSpeed optimization be automated?
- A large part of it can. A server-side PageSpeed optimizer can recompress and convert images, minify and combine CSS and JavaScript, add image dimensions and extend cache lifetimes with no change to the application. It cannot speed up slow application code, cut the amount of JavaScript a page runs, or manage third-party scripts.
- Is PageSpeed optimization the same as raising the PageSpeed Insights score?
- No. The 0 to 100 Performance score is one lab test on emulated hardware. PageSpeed optimization also covers field data: Core Web Vitals measured on real Chrome users over 28 days. A page can pass one and fail the other. Use the score to find problems and the field data to judge the result.
- Does PageSpeed optimization improve SEO?
- It can help and it guarantees nothing. Google states that Core Web Vitals are used by its ranking systems, that there is no single page experience signal, and that good results do not guarantee top rankings. It also says that chasing a perfect score only for SEO may not be the best use of your time.
- Source: Google Search Central on page experience
- How long does PageSpeed optimization take to show up in field data?
- Lab results change as soon as the optimized page is served. Field data moves slowly: PageSpeed Insights reports the Chrome User Experience Report over the previous 28-day collection period, so a fix made today is fully reflected about four weeks later.
- Is there a hosted PageSpeed optimization service?
- Google ran one, PageSpeed Service, and turned it off on 3 August 2015. Today the same kind of work is done by a CDN or edge service, by a CMS plugin, or by a module on your own server.
- Source: Google’s turndown notice for PageSpeed Service (archived)