-
Notifications
You must be signed in to change notification settings - Fork 12.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conditional comments wrapping <html> prevent IE from honouring <meta http-equiv=X-UA-Compatible> #1187
Comments
There was actually an issue raised about this previously - #378 |
Closing as dup of #378 |
Fwiw, the meta tag is far from foolproof. Unless you're completely handcuffed you should be setting the compar header on the server. |
Fine. I usually do anyway but it’s handy to have for local testing. It makes no sense to include in h5bp if it doesn’t do anything but looking at #378 I suspect arguing about it would just be pissing in the wind. |
You're saying it doesn't do anything? #378 says it simply doesn't prevent the compatibility view icon showing. |
As it stands the The |
If it has an effect on rendering I'm curious to see how this affects our view on XHTML compatibility. |
If that's true, then this isn't a dup of #378
How is it related to XHTML? |
I've been trying to nail this IE compatibility icon for a long time, and the only thing that worked was to add the HTTP headers to the response. Setting the X-UA-Compatible meta tag has no effect. The only on-page change that solved the issue was to remove the conditional comments wrapping the HTML tag. |
Does this mean then instead of it being |
I have a vested interest in making sure that H5BP doesn't let IE slip back into compat modes. jQuery 2.0 can't be used in IE 6/7/8, or in IE 9/10 where the user forces compat mode by accidentally clicking that infernal broken biscuit on the address bar. And yes, my scientific guess is that 90% of all clicks on the biscuit are accidental or misguided. Using X-UA-Compatible in either an HTTP header or a meta tag will get rid of the biscuit so users don't click it. It also overrides any listing in Microsoft's Compatibility View list, which companies might need to do if they're using H5BP to redesign a site that currently is on that list. They can't get Microsoft to take their site off the list until the migration is complete, but they need their new design to override the CV list. The absolute best way to avoid compat mode is for the site to send out the X-UA-Compatible HTTP header, because it avoids the need for IE to potentially restart a few lines down into the file when it sees the meta tag. However, a lot of companies have an organizational structure where the operations group that runs the server would never let some front-end Javascript jockeys tell them what headers they should send. So having a working X-UA-Compatible meta tag is the first line of defense. If the tag isn't going to help this IE situation, it should just be pulled out because devs are going to see it there, search for X-UA-Compatible, and think it's protecting them from compat mode, when it's not. But I'd much prefer to see it actually work. |
Without a test-case showing exactly how this is different from the known issue of the 'compatibility icon' being displayed (which is distinct from the claim that IE renders the page in compatibility mode), there's no new evidence to justify removing this line of code or making some other related change. If someone has a test-case, we can move forward. |
Start IE9 and go to this url: http://methvin.com/h5bp/ Your screen will look like this: http://i.imgur.com/WPkqp.png Now press the Compatibility View button on the toolbar. The result is this: http://i.imgur.com/QcBY4.png If the |
Thanks. Please can you throw up a control page too. |
I'm not sure what else you need, but if you describe your need for "throw up a control page" I can probably do it. That is a full stock install of h5bp 4.0.2, the only changes were to index.html and you can see those via view source. |
A control would be a "default" page against which the HTML5 Boilerplate code can be compared. In this case, it would be a page with the meta tag but no conditional comments around the opening |
Here is the control page: http://methvin.com/h5bp/index2.html Note that no compatibility view button appears on the address bar: http://i.imgur.com/yDJ68.png |
Remove or add an empty conditional comment to the top: http://stackoverflow.com/a/14588826/1072149 Here is a page without: http://o0.getsetbro.com/tests/ie_compat_view_broke.html Here is a page with it: http://o0.getsetbro.com/tests/ie_compat_view_fix.html |
@getsetbro That does appear to fix it! Man it's ugly tho. |
@getsetbro @dmethvin I had a look in IE10 on Windows 8 and didn't notice a difference... |
@getsetbro Gotcha. |
To be clear, when I said "fix it" I meant that will the leading comment IE9 doesn't show the compatibility view button on the URL bar, which is what I want since we don't want users to throw IE into compat view. |
Right. It does not keep the Browser Mode out of Compatibility View but it |
@dmethvin A different way to fix it would be to move the conditional |
In the original @paulirish blog post they were on the body, but were switched to the html tag. I'm not sure of all the history and pro/con behind it, although the blog post has a pretty decent audit trail. |
We moved it to the html element for performance reasons. As @dmethvin points out the whole story is captured in paul's post. I might write it up chronologically just for these discussions. |
@roblarsen The post mentions performance issues with conditional comments around link tags, not the body tag. Am I missing something? UPDATE: An additional empty conditional comment might be necessary: http://www.phpied.com/conditional-comments-block-downloads/#update |
Yeah, you're missing something. The conversation continued after the option of the empty comment was introduced (since people didn't like the empty comment.) A large part of the decision-making process on these kind of things happens in the comments. I'll write up the chronology just for clarity. |
That would be great, thanks! |
Does this suggest that stepping back to the "empty conditional" fix shown by Stoyan is in fact the ugly but pragmatic path to take (assuming projects that must support oldIE)? |
http://github.com/victoriafrench/defunctr would fix this. remove the conditional. Add class defunctr-ie-only to the html element. add the script after modernizr. There would be a difference in class names. Currenly this project uses .lt-ie8 etc. Defunctr uses .ie-lt-8 etc. But that is the only difference in generation. |
@victoriafrench Defunctr looks really good (I'm gonna try it), but I fear we want to be setting this as close as possible to the first thing rendered, which is why using conditionals around |
The reasons behind this decision include the following: * This project will drop legacy browser support (see #1050), therefore, the use for conditional classes for IE 8+, becomes much more limited. * IE 10+ does not support conditional comments: http://msdn.microsoft.com/en-us/library/ms537512%28v=VS.85%29.aspx. * Users do and can develop easily without using the conditional classes, this technique being very limited in scope as no other browser versions are explicitly target in the same way. * It fixes the issue that prevents IE from honouring `<meta http-equiv="X-UA-Compatible" content="IE=edge">` (see: #1187). This change also removes the related documentation. Close #1290 and #1187.
The reasons behind this decision include the following: * This project will drop legacy browser support (see h5bp#1050), therefore, the use for conditional classes for IE 8+, becomes much more limited. * IE 10+ does not support conditional comments: http://msdn.microsoft.com/en-us/library/ms537512%28v=VS.85%29.aspx. * Users do and can develop easily without using the conditional classes, this technique being very limited in scope as no other browser versions are explicitly target in the same way. * It fixes the issue that prevents IE from honouring `<meta http-equiv="X-UA-Compatible" content="IE=edge">` (see: h5bp#1187). This change also removes the related documentation. Close h5bp#1290 and h5bp#1187.
…onditional comments and IE6/7 hacks. Ref h5bp/html5-boilerplate#1050, h5bp/html5-boilerplate#1187 and h5bp/html5-boilerplate#1290
…onditional comments and IE6/7 hacks. Ref h5bp/html5-boilerplate#1050, h5bp/html5-boilerplate#1187 and h5bp/html5-boilerplate#1290
This:
prevents IE from honouring
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
.When you think about it, it’s fairly obvious why. IE can’t process conditional comments until it knows what version it’s pretending to be, and it doesn’t know what version it’s pretending to be until it has processed
X-UA-Compatible
.Symptoms:
X-UA-Compatible
, compatibility view is always turned off, which is what we modern web developers want).X-UA-Compatible
).It’s safe to wrap
<body>
instead, and just as useful (although this might break existing stylesheets if they rely on CSS classes being applied to the top-level element):(I’m assuming that the
no-js
class should still be applied to<html>
).The text was updated successfully, but these errors were encountered: