News for hackers. Stuff that matters.
Re:I'll sue you if you use my common-sense JavaScript tests by yannis on Sunday December 13, 2009 @10:09PM (#993514)
One of his quotes 'Every time a new browser version is released, anything built on them has to be re-tested due to an inexplicable reliance on the user agent string'.

Not really most libraries use feature testing, especially jQuery and John advocates feature testing in quite a few of his writings.

Re:I'll sue you if you use my common-sense JavaScript tests by DougBTX on Monday December 14, 2009 @08:29AM (#994088)
His point is more subtle - you can do browser detection based on user agent strings, feature detect, conditional script inclusion, even css hacks which set styles that can be read from javascript. His point (such that it is) is that these are all bad ideas.

Instead of detecting which browser you are using based on which features you support, the script should check to see if the features it wants to use exist, and if so use them.

So, instead of:

   var isIE = !!document.all;
   function doSomething()
   {
     if (isIE) document.all.whatever();
   }
You do:

   if (document.all)
   {
       function doSomething()
       {
           document.all.whatever();
       }
   }
Even closer to the point, he means that these are both bad form:

    var isIE = navigator.userAgent.ssubstr...;
    var isIE = !!document.all;
Re:I'll sue you if you use my common-sense JavaScript tests by thaumaturgy on Monday December 14, 2009 @09:02PM (#995640)
And this is fine in theory. I agree, as I think most other Javascript programmers do now.

However, I have a challenge for you: calculate the browser window's width in pixels, before the page is done loading, and return the correct value without doing any browser sniffing.

Enjoy. :-)