filter · HTML filters
Add instrumentation (add_instrumentation)
- Category:
- HTML
- CoreFilters:
- No
- OptimizeForBandwidth:
- No
- Risk:
- Test first
Injects JavaScript that measures page load time and reports it back to the mod_pagespeed statistics system via the beacon endpoint (/mod_pagespeed_beacon or /ngx_pagespeed_beacon). Enable this filter to get client-side performance data in the admin console histograms.
How it works
Test this filter before deploying to production. The injected JavaScript adds a small overhead and sends beacon requests on every page load.
Since v1.15.0+r18, with HonorCsp (default on) nothing is injected on pages whose Content-Security-Policy disallows the instrumentation script — no beacon fires for those pages, so they contribute no data to the console histograms.
When to use it
- Not in CoreFilters: it runs only when you enable it by name.
- Risk rating on these docs: Test first.
Risks
The
HTML filters
page lists no specific risks for this filter.
If a page misbehaves with it, DisableFilters add_instrumentation turns it off for
the scope you set it in.
Configuration
Enable it in the module configuration, at server, virtual-host or location scope:
Apache
ModPagespeedEnableFilters add_instrumentationnginx
pagespeed EnableFilters add_instrumentation;IIS (pagespeed.config)
pagespeed EnableFilters add_instrumentation
Scoping, ForbidFilters and the thresholds filters read:
Choosing filters
.
Live example
Adds a small client-side beacon that reports real load timings.
This filter changes how the page is structured or delivered, not its size, so the example shows a source diff rather than a byte or request reduction.
Frequently asked questions
- What does the add_instrumentation filter do?
- Injects JavaScript that measures page load time and reports it back to the mod_pagespeed statistics system via the beacon endpoint (
/mod_pagespeed_beaconor/ngx_pagespeed_beacon). Enable this filter to get client-side performance data in the admin console histograms. - Is add_instrumentation enabled by default?
- No.
add_instrumentationis not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name withEnableFilters. - How do I enable add_instrumentation on Apache and nginx?
- Add
ModPagespeedEnableFilters add_instrumentationon Apache orpagespeed EnableFilters add_instrumentation;on nginx. On IIS, addpagespeed EnableFilters add_instrumentationto pagespeed.config.
Related filters
- add_base_tag — Add base tag
- add_head — Add head
- add_ids — Add IDs
- collapse_whitespace — Collapse whitespace
- combine_heads — Combine heads
- compute_statistics — Compute HTML statistics
- convert_meta_tags — Convert meta tags
- debug — Debug comments
This page is drawn from the add_instrumentation entry on HTML filters. Every filter in one table: PageSpeed filters.