19 May 2010 5:32 AM #1
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
19 May 2010 5:50 AM #2
- Join Date
- Mar 2007
- The Netherlands
- Vote Rating
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).
19 May 2010 8:39 AM #3
19 May 2010 11:51 AM #4
Let me again point out some of the problems with sniffing:
if(Ext.isIE && !Ext.isIE8)Code:
isIE8 = isIE && check(/msie 8/)Code:
isIE6 = isIE && !isIE7 && !isIE8
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?
19 May 2010 12:01 PM #5
But as I said, I'm fully aware that it cannot be removed from everything.
23 May 2010 3:20 AM #6
Are there no-one interested in following up on this?
23 May 2010 3:58 AM #7
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:
Release Manager of TYPO3 4.5