Skip to main content

filter · HTML filters

Add head (add_head)

Category:
HTML
CoreFilters:
Yes
OptimizeForBandwidth:
No
Risk:
Generally safe

Adds a <head> element if the HTML lacks one. Several other filters inject content into <head>, so this filter ensures one exists. Runs automatically as a CoreFilter.

When to use it

  • In CoreFilters, the default RewriteLevel: it runs unless you disable it.
  • Risk rating on these docs: Generally safe.

Risks

The HTML filters page lists no specific risks for this filter. If a page misbehaves with it, DisableFilters add_head 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_head

nginx

pagespeed EnableFilters add_head;

IIS (pagespeed.config)

pagespeed EnableFilters add_head

It is on by default under CoreFilters; to turn it off:

ModPagespeedDisableFilters add_head   # Apache
pagespeed DisableFilters add_head;   # nginx
pagespeed DisableFilters add_head   # IIS

Scoping, ForbidFilters and the thresholds filters read: Choosing filters .

Frequently asked questions

What does the add_head filter do?
Adds a <head> element if the HTML lacks one. Several other filters inject content into <head>, so this filter ensures one exists. Runs automatically as a CoreFilter.
Is add_head enabled by default?
Yes. add_head is in CoreFilters, the default RewriteLevel, so it runs unless you turn it off with DisableFilters.
How do I turn off add_head?
Add ModPagespeedDisableFilters add_head on Apache or pagespeed DisableFilters add_head; on nginx. On IIS, add pagespeed DisableFilters add_head to pagespeed.config.

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

Search