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_headnginx
pagespeed EnableFilters add_head;IIS (pagespeed.config)
pagespeed EnableFilters add_headIt 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_headis in CoreFilters, the default RewriteLevel, so it runs unless you turn it off withDisableFilters. - How do I turn off add_head?
- Add
ModPagespeedDisableFilters add_headon Apache orpagespeed DisableFilters add_head;on nginx. On IIS, addpagespeed DisableFilters add_headto pagespeed.config.
Related filters
- add_base_tag — Add base tag
- add_ids — Add IDs
- add_instrumentation — Add instrumentation
- 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_head entry on HTML filters. Every filter in one table: PageSpeed filters.