0

Genesis Framework 2 has built-in support for loading the html5shiv.js, with the genesis_html5_ie_fix function (/lib/js/load-scripts.php).
I post the function below. It supposed to print a conditional comment in the head of the document, targeting IE 8 and lower versions.

Loading the website with any other browser, the comment exist in document's head. When I try to load it with IE8, the whole extra block is disappearing, and as a result, IE8 cannot understand the HTML5 tags.

If I remove the conditional comment and just leave the script tag, then it works okay, but the extra script is downloading for all browsers.

It looks like there must be something with IE8 having problem to parse the comment, or what?

*I have to say however that I am only checking IE8 through IE11 simulator (not sure if this is affecting the situation and how).

add_action( 'wp_head', 'genesis_html5_ie_fix' );

function genesis_html5_ie_fix() {

if ( ! genesis_html5() )
    return;

echo '<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->' . "\n";

}

1 Answer 1

1

According to Microsoft's docs, the syntax for revealing and hiding content using conditional comments are different, so since you're trying to only use (reveal) the script for IE8 and below (vs. hiding it), the echo statement should change to:

echo '<![if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]>' . "\n";

Support for conditional comments ended with IE10, so it may also be that the IE8 Compatibility View doesn't actually render the page with the old engine that supports CCs.

2
  • Valuable information here. I changed the echo's output following your recommendation, but still IE8 simulated from IE11, just disappearing it from the doc. So, think it should be related with your second assessment of the IE8 compatibility view.
    – FFrewin
    Jan 19, 2014 at 12:28
  • 1
    One way to verify is to use a virtual machine (check out modern.ie for free ones), or a service like BrowserStack (browserstack.com/list-of-browsers-and-platforms?product=live) to run your site on an actual IE8 browser. Testing on the actual platform is definitely the way to go. Jan 20, 2014 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.