Skip to main content

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_instrumentation

nginx

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.

See the before and after, with the source diff →

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_beacon or /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_instrumentation is not in CoreFilters, the default RewriteLevel; it runs only when you enable it by name with EnableFilters.
How do I enable add_instrumentation on Apache and nginx?
Add ModPagespeedEnableFilters add_instrumentation on Apache or pagespeed EnableFilters add_instrumentation; on nginx. On IIS, add pagespeed EnableFilters add_instrumentation to pagespeed.config.

This page is drawn from the add_instrumentation entry on HTML filters. Every filter in one table: PageSpeed filters.

Search