1. #1
    Sencha User
    Join Date
    Mar 2008
    Posts
    14
    Vote Rating
    0
    oyvind.kinsey is on a distinguished road

      0  

    Default Ext JS and browser sniffing

    Ext JS and browser sniffing


    It is a widely known fact that using UA sniffing to branch code is a bad idea, not only because its indirect (checking for window.ActiveXObject to see if we should use iframe.contentWindow or frames[iframename]), and because it is susceptible to errors due to modified UA string, but also because it is is inherently not forward compatible.

    And with 'not forward compatible' I mean two things (amongst many)
    * New agents that are not recognized might be subjected to invalid code paths rendering the application useless or crippled
    * Updated agents that support new features will not have these enabled

    So the main question here:
    With upcoming versions of Ext JS, are there any plans for switching to using feature detection instead?
    (And yes, I know that some things cannot be feature tested so UA sniffing will have to be kept for those).
    Last edited by oyvind.kinsey; 19 May 2010 at 5:55 AM. Reason: Additional text

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    You would think that this is a good solution, but unfortunately you can't sniff more than half of the required features (e.g. css quirks).

    The problem with unrecognized or new browsers is that they probably will require changes in Ext anyway (there hasn't been a major browser release yet that behaved identical to another browser).

    Also, browser programmers are completely aware of the fact that the user agent string is used for version checking, so they won't easily break the syntax (the only exception I know is SRWare Iron which for some strange reason doesn't have Chrome in its user agent string).

  3. #3
    Sencha User Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    Quote Originally Posted by oyvind.kinsey View Post
    With upcoming versions of Ext JS, are there any plans for switching to using feature detection instead?
    (And yes, I know that some things cannot be feature tested so UA sniffing will have to be kept for those).
    Yes, we do plan to use feature detection as much as possible in our next major release. Keep in mind that some level of UA will unfortunately have to stay as just because a browser may allow a certain feature, doesn't mean it does it well.

  4. #4
    Sencha User
    Join Date
    Mar 2008
    Posts
    14
    Vote Rating
    0
    oyvind.kinsey is on a distinguished road

      0  

    Default


    Quote Originally Posted by Jamie Avins View Post
    Yes, we do plan to use feature detection as much as possible in our next major release. Keep in mind that some level of UA will unfortunately have to stay as just because a browser may allow a certain feature, doesn't mean it does it well.
    Does this mean that new features will be based on feature detection, or that old features will be rewritten properly?

    Let me again point out some of the problems with sniffing:
    All
    Code:
    if(Ext.isIE && !Ext.isIE8)
    based codepaths are going to fail in existing versions of ExtJs when IE9 comes as Ext will not recognize the browser.
    Code:
    isIE8 = isIE && check(/msie 8/)
    This mean that all sites that are built with e.g Ext 3.2.1 will/might break when used with IE9 as Ext believes that it is IE6
    Code:
    isIE6 = isIE && !isIE7 && !isIE8
    (This is seriously bad code!) - hopefully IE9 will be very different from IE6.

    Having to manually revisit all such branches to see if a check should be made for a never version is extremely prone to error (and not to say unnecessary with feature detection), something that could be seen with 3.2 as its DragDropMgr did not take into account that IE8 works differently from IE6 and so would introduce strange and unexpected behavior (not sure if this has been fixed with 3.2.1).

    The point is, UA sniffing is bad for everybody
    - the ExtJS developers as these develop according to what they believe a specific browser can do, instead of what the current actually can do
    - the developers that use ExtJS as these are forced to upgrade their sites as new browsers enters the marked, unless willing to let the sites break in these. This is not a valid approach as not everyone can take that cost, and quite frankly, they shouldn't have to
    - the users as they will see applications that worked in older browser break when viewed in newer ones

    So to restate the question, will we see a complete rewrite, or is it only new features that will use feature detection?

  5. #5
    Sencha User
    Join Date
    Mar 2008
    Posts
    14
    Vote Rating
    0
    oyvind.kinsey is on a distinguished road

      0  

    Default


    Quote Originally Posted by Condor View Post
    You would think that this is a good solution, but unfortunately you can't sniff more than half of the required features (e.g. css quirks).
    Actually, most CSS quirks can easily be feature tested. For instance, IE6's padding issue can easily be detected by adding an element to the dom and the measuring its rendered size.
    But as I said, I'm fully aware that it cannot be removed from everything.

    Quote Originally Posted by Condor View Post
    The problem with unrecognized or new browsers is that they probably will require changes in Ext anyway (there hasn't been a major browser release yet that behaved identical to another browser).
    Not if properly feature tested: testing how the browser treats paddings relating to width/height will allways return the proper result - either the padding is added, or it is not.
    Quote Originally Posted by Condor View Post
    Also, browser programmers are completely aware of the fact that the user agent string is used for version checking, so they won't easily break the syntax (the only exception I know is SRWare Iron which for some strange reason doesn't have Chrome in its user agent string).
    Perhaps you should look more into the issue - the point is that you are going to have a hard time finding good arguments for why UA sniffing is better than feature detection. It might be simpler right now (knowing what we know of the current reality), but its bound to create problems later (as we know nothing about the coming reality).

  6. #6
    Sencha User
    Join Date
    Mar 2008
    Posts
    14
    Vote Rating
    0
    oyvind.kinsey is on a distinguished road

      0  

    Default


    Are there no-one interested in following up on this?

  7. #7
    Sencha User steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,664
    Vote Rating
    7
    steffenk has a spectacular aura about steffenk has a spectacular aura about steffenk has a spectacular aura about

      0  

    Default


    I'm currently working on browser sniffing from UA (in php), and there are , what a wonder, problems with IE. IE sends multiple versions, eg IE8 sends msie 8.0 and msie 6.0. So it's not an easy task.

    Helpful is this site:
    http://www.useragentstring.com/
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5