why are conditional comments implemented in IE? [closed]
less of how & more of a why question here...I tried searching around some & couldn't quite find the answer I was looking for.
I'm curious why conditional comments exist within IE? did Microsoft implement this into the different browser versions because they knew they were not standards compliant?
I know certain version of other b开发者_JS百科rowsers can be targeted using conditional comments but those for IE far outnumber any other browsers.
I'd be interested in hearing any info regarding the origin & history of conditional comments.
They implemented it with ie5 and saw it as a good thing to optimise sites for IE.
Conditional comments have certain advantages over scripting methods of browser detection.
- Low client-side impact.
When a downlevel browser encounters a downlevel-hidden conditional comment, the browser skips over the HTML inside the comment, and the content elements are not parsed, downloaded, or rendered. This saves client machine resources.
- No script required.
Conditional comments do not require scripting and DHTML, and when no scripting is used in a Web page, no scripting engine needs to be loaded. Conditional comments are processed during the downloading and parsing phase, so only the content that is targeted for the browser is actually downloaded. Conditional comments can be combined freely with other browser detection techniques.
- Separate code from detection logic.
Using conditional comments, script logic can be separated into smaller and simpler segments of code, which are easier to maintain and understand. Plus, code segments are loaded only by the browser version for which they were intended.
- Cross-browser.
Conditional comments have been around since Internet Explorer 5, but their use is not restricted to Internet Explorer alone. Conditional comments can be used to customize content delivered to browsers that support conditional comments and those that do not.
more info: http://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx
精彩评论