Internet Explorer 10 / IE11 – Drops Conditional Comments – Solutions

Internet Explorer 10 - Conditional CommentsIf you were expecting something good — sorry to disappoint you. This is a rant (though I tried to include some helpful code and a link for 2 methods of dealing with this). Regardless, IE10 dropping conditional comment support is OLD NEWS to many of you.

When Internet Explorer 10 was released, Microsoft decided to get rid of conditional comments.

Is this good? Or is it bad?

In my opinion — it is BAD. Conditional comments are looked at often by some developers as a bandaid to an underlying issue. And you know what? They are.

But does that mean remove them? No, not at all. It helps future-proof the browser. There are times when you truly need them.

So what do we do now?

We can use JavaScript or PHP to detect the browser and spit out a solution to the problem.

An example that utilizes JavaScript can be seen here.

And PHP for detection?

if(preg_match('/(?i)msie [10]/',$_SERVER['HTTP_USER_AGENT'])) { ...

It’s a start. Feel free to share your suggestions or comment as to why you think conditional comment support being dropped is good / bad.

Edit: Just FYI — Internet Explorer 11 (IE11) ALSO has no conditional comments, as you may have expected. You can check more information on that here from Microsoft’s website.

No Responses

Leave a Reply

Your email address will not be published.