Sometime over the past week, my Windows 7 machine did some updates that, amazingly, included an auto-update of IE10 to IE11. This is great news. This is the first time I’ve heard of any version of IE being pushed out automatically as a “critical” update (which I assume is what it did, since I don’t ever do the optional updates and those don’t happen automatically).
Those who have checked out IE11 have probably noticed a visual overhaul to the developer tools. One particular thing I noticed is that the “document mode” and “browser mode” options that were present in IE10’s tools have now been integrated into something called “Emulation” (which you can open quickly by hitting F12 then CTRL-8).
Evidently, when the IE11 preview was launched, the developer tools did not include this emulation mode. But due to developer outcry, it was added. You can see this in the IE Team’s response in this bug report.
Unfortunately, after testing out Emulation mode in IE11’s developer tools, one glaring problem is the fact that these do not support conditional comments. This is a huge problem for anyone using IE11 in different modes (IE7, IE8, and IE9).
But first, let’s clear something up.
Use VMs, not Emulation
Nobody should depend on IE10 or IE11’s emulation of older versions of IE. They just aren’t reliable. Generally, what I do is use the quick browser/document modes to do some basic CSS layout checks and to ensure my styles are being applied when I use conditionals or hacks to target IE8.
The Bizarre World of IE11’s Emulation Modes
Having said that, the question remains: Why include IE5/7/8/9 emulation, if those emulation modes don’t support conditional comments?
What’s interesting is that the support for CCs seems to be not fully lacking, just really weird. For example:
- If you do just a plain
<!--[if IE ]>, it works fine.
- If you make a syntax error in your conditional (e.g.
<!--[if (IE ]>), then the entire comment will appear on the page (was this happening before? Maybe, I don’t know.)
- If you do
<!--[if !IE ]>nothing will happen (which is correct), but if you do
<!--[if !IE8 ]>(or 5, 7 or 9), the content will appear in any emulated version that supports CCs (not 10), even the version you’re saying “not” to.
So the only thing you can do that works correctly is use “if IE”. I suppose this is better than nothing, because then you could just target the different versions of IE with hacks. But that’s not really the end goal here. In my opinion, the usefulness of the emulation modes is to help with some quick simple checks and then save the big testing for the VMs. At least that’s how I look at it (although I’ve never had the need to use the VMs, personally).
And please take note: This is not about support for CCs in IE11. As was announced some time ago, versions of IE from IE10 and up will no longer support conditional comments.
If anyone has any further info on this, feel free to comment and I’ll update accordingly. Hopefully any future updates to IE11’s developer tools will either fix this problem or remove the emulation mode altogether (which might realistically be a better option for all developers).