Add Head

Configuration

The 'Add Head' filter is enabled by specifying:

Apache:
ModPagespeedEnableFilters add_head
Nginx:
pagespeed EnableFilters add_head;

in the configuration file, but it is also enabled automatically by several other filters, including combine_heads, move_css_to_head, and add_instrumentation.

Description

The 'Add Head' filter is very simple: it adds a head to the document if it encounters a <body> tag before finding a <head> tag.

For example, if the HTML document looks like this:

<html>
  <body>
    <div class="blue yellow big bold">
      Hello, world!
    </div>
  </body>
</html>

Then PageSpeed will rewrite it into:

<html>
  <head>
  </head>
  <body>
    <div class="blue yellow big bold">
      Hello, world!
    </div>
  </body>
</html>

Note

This filter exists primarily to ensure that other filters have a place to insert new tags that needs to be in the head, or that trigger on the closing-tag for a head to perform some other action.

Risks

This filter is considered minimal risk.