• kingofpain (unregistered)

    never had the courage to write that comment....

  • T$ (unregistered)

    I like also how the IE7 stuff is commented out.

    My favorite is several lines up:

    <!--[if IE 6]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie6.css" type="text/css" rel="stylesheet"></link> <![endif]--> <!--[if IE 7]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie7.css" type="text/css" rel="stylesheet"></link> <![endif]-->

    All commented out, mind you. Good thing this is production-quality code!

  • DOA (unregistered)

    Looks reasonable. With Javascript you reach a point where there's nothing to do but plead

  • bstorer (cs) in reply to T$
    T$:
    I like also how the IE7 stuff is commented out.

    My favorite is several lines up:

    <!--[if IE 6]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie6.css" type="text/css" rel="stylesheet"></link> <![endif]--> <!--[if IE 7]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie7.css" type="text/css" rel="stylesheet"></link> <![endif]-->

    All commented out, mind you. Good thing this is production-quality code!

    IE supports conditional comments. See here: http://www.quirksmode.org/css/condcom.html

  • j_melt (cs)

    Say what you will, but it worked. I viewed the page from IE7 and it didn't crash. ;-)

  • T$ (unregistered) in reply to bstorer

    I had no idea, interesting. I like it.

  • Einsidler (cs) in reply to bstorer
    bstorer:
    T$:
    I like also how the IE7 stuff is commented out.

    My favorite is several lines up:

    <!--[if IE 6]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie6.css" type="text/css" rel="stylesheet"></link> <![endif]--> <!--[if IE 7]> <link media="screen" href="/vstatic/16cce2360fa5810fe5ae3c8b076d0009/static/css/ie7.css" type="text/css" rel="stylesheet"></link> <![endif]-->

    All commented out, mind you. Good thing this is production-quality code!

    IE supports conditional comments. See here: http://www.quirksmode.org/css/condcom.html

    oh ffs, that is the real WTF, though I can see it is useful in situations that shouldn't arise in the first place.

  • samy (unregistered) in reply to T$

    The question is whether implementing such non-standard features in a browser solves the problem or IS the problem.

  • BlueKnot (unregistered) in reply to samy
    samy:
    The question is whether implementing such non-standard features in a browser solves the problem or IS the problem.
    It's a new problem designed to counter the previous problem? Offsetting problems, so the net result is workable? Sounds like a strategy I've heard before...
  • Pidgeot (unregistered) in reply to Einsidler
    Einsidler:
    oh ffs, that is the real WTF, though I can see it is useful in situations that shouldn't arise in the first place.

    IE's solution is by far the most elegant way to check which browser the client is using, and act accordingly, regardless of why you need it. For all other browsers, you need to check for non-existant properties/methods/whatever in Javascript, and then act accordingly within the Javascript - terrible idea if you need to add special CSS, and the method will obviously fail when the user doesn't have JavaScript enabled, or when the browser you're handling adds that property, but doesn't fix the reason you put it there in the first place. User-agent checking is utterly useless and unreliable, as it's extremely easy to change it.

    As long as any browser that is even remotely likely to be used for your site, doesn't render 100% according to standard (last I checked, Opera was the closest, but not perfect), you need a way to differentiate between them to work around limitations. Using Javascript is okay if only the Javascript needs to be different, but if you're trying to avoid a bug in a Firefox' CSS engine (of which there are plenty), that's when conditional comments would be very handy, as they are 100% reliable.

  • Marshall (unregistered)

    I think the real WTF is the compression used in that pic.

  • RON (unregistered) in reply to samy
    samy:
    The question is whether implementing such non-standard features in a browser solves the problem or IS the problem.

    The W3C is a joke. It takes years of idiotic committee bickering to get anything done, and when they finally do make a decision, it's usually half-assed.

    Reminds me of AJAX. When Microsoft invented it (yep, you read that right, they invented it), everyone bitched about how it was useless and how it broke standards, yadda yadda.

    But then people realised how useful it actually was, and embraced it like crazy.

    Yell at MS for "breaking" standards if you wish, but honestly, that's ridiculous. MS, like most web developers I know, is sick of the W3C dragging its heels on shit that should have been made 10 years ago.

  • Frymaster (unregistered) in reply to Pidgeot

    The alternative to conditional comments is the horrible system of hacks many CSS "gurus" use, which involves exploiting various parsing errors in various versions of IE in order to allow parts of the CSS to be bypassed or not, depending. For some reason they feel this is a better solution (and then moan when something new - like IE7 - comes along which isn't bug-compatible with IE6)

  • Shinobu (unregistered) in reply to RON

    And other browser vendors apparently agree, as both Firefox and Konqueror have stapped beyond the limits of the W3D standards.

  • Sascha Leib (unregistered)

    I know the pain, because programming JS cost me a significant number of hair already.

    I must say, though, that discovering the 'Prototype' library has eased my pain considerably. I really helps to get things done in a browser-independent way.

    /sascha

    Hm, captcha is "doom". Does that mean anything? ;-)

  • shakin (cs) in reply to RON

    Saying that Microsoft invented AJAX is such a simplistic view of AJAX that it's plain wrong. Microsoft invented the XMLHttpRequest object, which is a very important part of the group of technologies we call AJAX. The iFrame as well as Netscape's scriptable layer element are both precursors to AJAX and had a strong influence, making XMLHttpRequest more of an evolution of existing ideas rather than a completely new concept. DHTML is the rightful precursor to AJAX as a way to make pages dynamic and even dynamically include server side content.

  • lazloman (cs)

    He should also offer a cigar and rum to Jobu!

  • Hit (unregistered)

    Javascript has been a WTF from the start. So it isn't surprising that it grows into a bigger WTF as time marches on. When you start with a foundation of shit, it's not unexpected that you will find a shaky, unstable building on top of it.

    A bit of history. Javascript started as a netscape 3.0 invention. It was designed as a "quick and dirty" way to get Netscape to do cool things, since HTML was not designed for the sorts of behavior needed. There was no Javascript "standard" back then...there didn't need to be. Netscape WAS the standard.

    IE4 and 5 come along and takes up the torch, adding more crud (and features, sometimes hard to tell the difference) to the javascript language. Netscape dies out (and I'm not sorry to see it go, Netscape 4.x is one of the biggest WTFs in history, IMO) and IE's javascript is now the "standard". Oh, there's an EMCA standard by now, but let's not kid ourselves, the true web standard continues to be whatever the most popular browser is at the time, bugs and all.

    Firefox comes along, taking a significant share from IE. It too, adds it own javascript features/crud, further adding to the nightmare that is cross browser compatibility.

    What's worse, is now that "AJAX" has come along, javascript has become even more integral to the browser "experience".
    Further, new web cool web browsers will come along (those who believe it's "Firefox forever" are deluding themselves, history says otherwise) they'll add their own "flavor" of javascript, thus muddying the waters further.

    So to some up, a quick and dirty hack of a scripting language becomes something that it was never intended to when it was conceived. As as result, web developers will continue to be pulling their hair out in the forseeable future.

  • FredSaw (cs) in reply to Hit
    Hit:
    So to some up, a quick and dirty hack of a scripting language becomes something that it was never intended to when it was conceived. As as result, web developers will continue to be pulling their hair out in the forseeable future.
    Alex Fleming's penchant for keeping a nasty, filthy, disorganized laboratory led to the discovery of penicillin. Sometimes things work out well by serendipity.
  • Mcoder (cs) in reply to Pidgeot
    Pidgeot:
    Einsidler:
    oh ffs, that is the real WTF, though I can see it is useful in situations that shouldn't arise in the first place.

    IE's solution is by far the most elegant way to check which browser the client is using, and act accordingly, regardless of why you need it. For all other browsers, you need to check for non-existant properties/methods/whatever in Javascript, and then act accordingly within the Javascript - terrible idea if you need to add special CSS, and the method will obviously fail when the user doesn't have JavaScript enabled, or when the browser you're handling adds that property, but doesn't fix the reason you put it there in the first place. User-agent checking is utterly useless and unreliable, as it's extremely easy to change it.

    One would expect the JavaScript standard to have some builtin value that lets one know what the browser is... But, of course, it couldn't really get anything usefull on it.

    I also don't blame Microsoft for the crude workaround.

  • sol (unregistered)

    Actually JavaScript was originally called LiveScript not JavaScript. Browsers are evil and the only thing that matters is how it renders in Dos, if it passes the stupid xhtml 1.0 validation test, and google can properly index it. So that said everything should be made in Falsh that way you can tell the browser to go to hell! Natch!

    [This site made in Notepad]

  • yafake (unregistered)

    The real WTF is that people still believe in the "conditional comments" nonsense. If they would actually try, then they'd notice that it doesn't make any difference if you write "if lt IE6" or "if gte IE6" or "if lt IE7" of "if lt foobar" or "omgwtf" or nothing at all. There is no such thing like conditional comments, it's Microsoft's lame excuse for not properly implementing the parsing of SGML comments.

    Trivial test case:

    <!-->This is a HTML comment. Don't show me!<!-->
  • sol (unregistered)

    hmm why not use javascript to load javascript files and render them... you know run the check the browser and then use ajax to load you neat well made browser specific javascript....

    you know something really easy to maintain like this:

    <script>document.write("\<script\>document.write(\"foo\");\</script\>");</script>
  • JayTee (unregistered) in reply to Hit
    Hit:
    Javascript has been a WTF from the start. So it isn't surprising that it grows into a bigger WTF as time marches on.
    When did Javascript become worse than failure? It's actually a robust, powerful language - the problems you speak of are the browser implementations of the language.
    Hit:
    A bit of history. Javascript started as a netscape 3.0 invention. It was designed as a "quick and dirty" way to get Netscape to do cool things, since HTML was not designed for the sorts of behavior needed. There was no Javascript "standard" back then...there didn't need to be. Netscape WAS the standard.
    Actually Netscape 2.0 in 1995
    Hit:
    IE4 and 5 come along and takes up the torch, adding more crud (and features, sometimes hard to tell the difference) to the javascript language.
    Microsoft created it's own implementation and called it "JScript" - they didn't actually change javascript.
    Hit:
    ...the true web standard continues to be whatever the most popular browser is at the time, bugs and all.
    On what planet? IE is the least standards-compliant browser and Microsoft sits on the W3C and were part of the ECMA standardization!
    Hit:
    Firefox comes along, taking a significant share from IE. It too, adds it own javascript features/crud, further adding to the nightmare that is cross browser compatibility.

    Really? What got added? As far as I can tell, the mantra amongst developers is "Code your site correctly, then make it work in IE"

    Hit:
    What's worse, is now that "AJAX" has come along, javascript has become even more integral to the browser "experience". Further, new web cool web browsers will come along (those who believe it's "Firefox forever" are deluding themselves, history says otherwise) they'll add their own "flavor" of javascript, thus muddying the waters further.

    I think you're stuck in the 90's.

    Hit:
    So to some up, a quick and dirty hack of a scripting language becomes something that it was never intended to when it was conceived. As as result, web developers will continue to be pulling their hair out in the forseeable future.

    I think you'll find that the language isn't to blame. It's the browser implementation of the language. Just because IE is the majority browser, it doesn't make it's implementation more correct. In fact, the biggest problem between IE and the rest of the world lies in it's handling of CSS rules rather than it's JavaScript engine.

    Most of the issues that exist between the browsers now are relics of the poor implementations of the past. For example, Microsoft held on to it's old style of event management to maintain compatibility with older web pages - thus we still have memory leaks in IE.

  • whoahman (cs) in reply to Mcoder
    Mcoder:
    One would expect the JavaScript standard to have some builtin value that lets one know what the browser is... But, of course, it couldn't really get anything usefull on it.

    I also don't blame Microsoft for the crude workaround.

    Using Javascript to determine what stylesheets to load... now that is a real WTF.

    Conditional comments are a far more elegant and performant solution to the problem of backwards compatibility.

  • B (unregistered) in reply to T$
    Comment held for moderation.
  • James (unregistered)

    Two wrongs <comment>do not</comment> make a right?

  • AndyG (unregistered) in reply to Hit
    Hit:
    So to some up, a quick and dirty hack of a scripting language becomes something that it was never intended to when it was conceived. As as result, web developers will continue to be pulling their hair out in the forseeable future.

    Not to sound like a JavaScript apologist, but I think this is a little harsh. The problem, as far as I can see is, is not with Javascript [the language] as it is with the shoddy bindings to the various browsers.

    As a language in itself, JavaScript has a lot of nice features that make it well suited to application automation - loose typing, first class functions and closures. The design of the language is compact, reasonably elegant, and more orthogonal than most. The syntax is easy and familiar to almost anyone who has programmed one of the C-like family (which includes PHP and Perl as honorary members, I guess).

    However, I agree that the 'design' of the browser environment it commonly runs in is dreck. It's a lot nicer now that there's access to the XML DOM methods across all the major browsers, meaning that you don't have to jump through hoops to figure out which container to look in for your objects, but it's still a gnarly collection of badly thought-out mismatched APIs. And then you have CSS, which has its own collection of idiocies to layer on top.

    It does concern me that AJAX is rooted in such an ad-hoc environment. It is obviously not the best solution for distributed application delivery, but then the web browser has always been a nasty, limited place to run applications. That hasn't stopped us all from writing and using web apps for the last ten years, though. The platform is a ubiquitous lowest common denominator, and it turns out that the benefits it delivers (zero installation, easy centralized roll-out of functionality) outweigh most of the other technical considerations, simply on the basis of cost. We are going to be stuck with it, regardless of what we feel might be better.

  • Logan Bowers (unregistered)

    There was a bug in IE that caused the page to crash whenever the DOM element containing the comment was empty. It didn't matter what was there as long as it was something, so one of the devs added the "please don't crash" comment. And IE listened.

  • nilp (cs) in reply to JayTee
    JayTee:
    Microsoft created it's own implementation and called it "JScript" - they didn't actually change javascript.

    Oh man, that reminds me. I recently had to maintain some Javascript/HTML code that was supposed to display an error message if the browser wasn't IE. Of course, the script was written in JScript, so non-IE users saw a blank page while IE users saw what they were supposed to see.

    I fixed it by removing the browser check and rewriting a few lines of script so that all browsers later than NS4 could see the page perfectly fine.

  • Corey (unregistered) in reply to lazloman
    lazloman:
    He should also offer a cigar and rum to Jobu!
    Jesus I like very much, but he no help with JavaScript.
  • ChrisH (unregistered) in reply to RON
    <soapbox>

    Well I guess I'm in the wrong crowd here but AJAX does break standards if used inappropriately. Many a muppet has gleefully broken previously accessible sites, without thinking to develop for other previously perfectly working platform/browsers because... "Aye! It wuks on IEee on me Winduz box, like." ...so that must be alright then.

    As for the W3C, well there's nobody in the industry who thinks the the rubbish that happened in the browser wars was good. It took years to get everybody back on the same track and even now we "need" IE conditional comments. I'd rather wait for robustness and standards than spend endless development hours reworking code for every browser and platform there is.

    We actually had the ability to do AJAXy stuff without XHR. People smart enough to know how were smart enough not to go splashing it around at every opportunity. </soapbox>

    But I digress, the plea in the comment mad me and everybody in the office laugh. The rest of the <head></head> code was fine AFAIC although I would try to design without the need for conditional comments.

  • Jeff Lubetkin (unregistered) in reply to Logan Bowers
    There was a bug in IE that caused the page to crash whenever the DOM element containing the comment was empty. It didn't matter what was there as long as it was something, so one of the devs added the "please don't crash" comment. And IE listened.

    I am the author of this little snippet of joy. During the final frantic stages of getting Zillow out the door, a bug was discovered where if a certain DIV was completely empty, IE6 would crash. Hard. It was likely a combination of the DIV naming and the CSS being applied, but we didn't have days to waste tracking it down. In desperation, I added this comment to see if simply adding anything to the DIV would prevent the crash...and it worked. I suppose I could have been more cryptic, but as we all know it's important to future maintenance that any code be self-explanatory.

    Given major changes to the DOM structure and CSS of the site, it's likely that this comment isn't even necessary anymore, but I've always liked the fact that I fixed a crashing bug with a comment. Plus, it got me on WorseThanFailure.com, and how many devs can say that?

    Oh, and while the Javascript discussion above is interesting, keep in mind that this bug had nothing to do with scripting, but with the DOM and CSS in IE6. Even with no script at all on the page, it still crashed...

    jeff

  • NeverYouMinfd (unregistered) in reply to ChrisH
    Javascript isn't for the weak of heart or those short of patience. What works in one browser may not function properly, or result in a nasty JS error in another (*cough*IE*cough).

    Or the user can DISABLE it entirely, or perhaps their network administrator has locked down their browser security settings, or...

    There are a myriad of reasons that javascript might not work. There is NO WAY to guarantee that javascript will work, therefore it is completely useless and anyone who relies on it is a fool.

  • my name (unregistered) in reply to Jeff Lubetkin
    Jeff Lubetkin:
    I am the author of this little snippet of joy. During the final frantic stages of getting Zillow out the door, a bug was discovered where if a certain DIV was completely empty, IE6 would crash. Hard. It was likely a combination of the DIV naming and the CSS being applied, but we didn't have days to waste tracking it down. In desperation, I added this comment to see if simply adding anything to the DIV would prevent the crash...and it worked.
    A comment that affects how the program runs. I love it.
  • theultramage (unregistered)
    Comment held for moderation.
  • Anonymous (unregistered) in reply to theultramage
    Comment held for moderation.
  • Anonymous (unregistered)

    Eww, i'm taking that back - it doesn't. Half-fixed, oh my.

  • rycamor (unregistered) in reply to NeverYouMinfd
    NeverYouMinfd:
    Javascript isn't for the weak of heart or those short of patience. What works in one browser may not function properly, or result in a nasty JS error in another (*cough*IE*cough).

    Or the user can DISABLE it entirely, or perhaps their network administrator has locked down their browser security settings, or...

    There are a myriad of reasons that javascript might not work. There is NO WAY to guarantee that javascript will work, therefore it is completely useless and anyone who relies on it is a fool.

    Yes, Google developers were such fools to write Gmail. There's no way anyone's going to use that piece of garbage, because they just might have Javascript turned off and be completely unable to figure out how to turn it on again.

  • Aaron (unregistered)

    I have to deal with reconciling standards-compliant code with IE's buggy box model all day long. Conditional comments are SOOOOOOO useful. It's much easier to keep two separate CSS files -- one for everyone, and one for IE. You render the standard one first, then render the IE one and have it overwrite the CSS rules that need fixed.

    It's clean, easy, and it WORKS (even as far back as IE5!).

    It's quite frustrating when you finally finish all the CSS styles in Firefox / Safari, and all of a sudden you realize that it totally displays incorrectly in IE. And whoever said that MS created the XHR is indeed correct. They did create it way back in the day. It was just never effectively implemented until recently.

    Oh -- and to fix the code author's problem with IE crashing from empty DIV tags: stick an   in there. That's enough to keep IE happy.

  • Random832 (cs) in reply to ChrisH
    ChrisH:
    <soapbox>We actually had the ability to do AJAXy stuff without XHR. People smart enough to know how were smart enough not to go splashing it around at every opportunity. </soapbox>

    How do you do it with the Netscape 4 model? Well, first you have to make a new hidden layer, with the SRC being the bit you're requesting from the server. Then you read from the... wait, what? no document.read()?

    "AJAXy stuff" requires the ability to make fresh data from the server available to a script.

    IE4's InnerHTML/InsertAdjacentHTML/etc model was the first one in which anything resembling AJAX was possible. Minimally, you need to be able to load a second document (e.g. in a frame), and get the content out of that document so you can do scripty things with it.

  • rycamor (unregistered)
    Comment held for moderation.
  • Random832 (cs) in reply to rycamor
    rycamor:
    Hacker/guru: Javascript is such a nice clean language! Too bad there's no good implementation for general programming. It would make a better all-purpose scripting language than most of the other crap we use. Imagine a Unix shell using Javascript!

    I'm actually looking into how difficult it would be to make one based on Spidermonkey in my spare time. Would you like to work on such a project?

  • fej (unregistered) in reply to my name
    my name:
    A comment that affects how the program runs. I love it.

    good old days of Pascal, where you had to write some conditinal comments {$+} to be able to work with files..

  • prefect (unregistered) in reply to shakin
    Comment held for moderation.
  • Look at me! I'm on the internets! (unregistered) in reply to Anonymous
    Comment held for moderation.
  • rycamor (unregistered) in reply to Random832
    Comment held for moderation.
  • Random832 (cs) in reply to JayTee
    JayTee:
    Hit:
    Firefox comes along, taking a significant share from IE. It too, adds it own javascript features/crud, further adding to the nightmare that is cross browser compatibility.

    Really? What got added?

    It added quite a bit of stuff that would actually be really cool to have, if it were supported everywhere - defineSetter is one that comes to mind immediately.

  • yafake (unregistered)

    As I said: A big WTF. People are still discussing about the non-existent conditional comments that they believe in so much, despite being shown that they don't exist, Microsoft told them BS, and it's actually a bug in IE being abused.

  • webrunner (cs)

    I find it funny that the Script tag allows you to put all sorts of different content types in it, but there's only what, three, that browsers will ever read?

    Anyway, I was a fan of the W3C until I started dealing with the xhtml depreciations- they depreciated things without quick replacements. For example: there's no default tag that defaults to text-decoration:underline; in xhtml. To be compliant you have to use <span style='text-decoration:underline;> or or re-format cite or something.

Leave a comment on “A Plea from the Heart”

Log In or post as a guest

Replying to comment #:

« Return to Article