Skip to content

Instantly share code, notes, and snippets.

@blainerobison
Created August 18, 2015 21:53
Show Gist options
  • Save blainerobison/b98dbb25c59b810ccd20 to your computer and use it in GitHub Desktop.
Save blainerobison/b98dbb25c59b810ccd20 to your computer and use it in GitHub Desktop.
WordPress X-UA-Compatible Headers for IE
/**
* Set X-UA-Compatible for IE
*
* Sends headers to browser in an attempt to have IE render the website using
* their latest rendering engine (i.e. IE=edge). Additionally, attempts to
* activate Chrome Frame add-on if it exists.
*
* IE browser may show compatibility icon in address bar when using HTML5 Boilerplate's
* heading markup which contains conditional comments on HTML tag.
*
* Setting the X-UA-Compatible meta tag will not work if placed after the HTML
* conditional comments.
*
* While there are workarounds, the preferred method is to send headers, not markup.
*
* IE should attempt to render website using its "stable" engine. I believe as
* of IE10, this is edge.
*
* @link Explanation of values: http://stackoverflow.com/a/14637972/3163972
* @link Solution: http://stackoverflow.com/a/9624500/3163972
* @link HTML5 Boilerplate's Take: https://github.com/h5bp/html5-boilerplate/issues/378
* @link Reasons Compatibility Mode may be set: http://stackoverflow.com/a/3726605/3163972
*/
function prefix_add_header_xua() {
header( 'X-UA-Compatible: IE=edge,chrome=1' );
}
add_action( 'send_headers', 'prefix_add_header_xua' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment