I was wondering why javascript os detection techniques like navigator.userAgent, navigator.appName, navigator.appVersion and navigator.platform are in process of being dropped from web standards.
https://developer.mozilla.org/en-US/docs/Web/API/Navigator
If you visit every of those navigator props, you can see
Deprecated
This feature has been removed from the Web standards. Though some browsers may still support it, it is in the process of being dropped. Do not use it in old or new projects. Pages or Web apps using it may break at any time.
So I would like to know
- Why they're removing this
- Will they introduce a new way for OS detection
- Can I use these techniques even if they're deprecated.
Probably there is a lot of cases where we need to know OS version.
navigator.appName
is "Netscape" which has zero information value. – Archduchynavigator.platform
is being deprecated. Other than MDN (which is community-edited and therefore sometimes incorrect, if generally very good), do you have any reference for that?appName
andappCodeName
are (the spec says they should always be"Netscape"
and"Mozilla"
, respectively), but notplatform
as far as I've heard. – Leishanavigator.userAgent
either for the same reasons, in firefox you can change the preference general.useragent.override in about:config. -- browser detection is a bad idea, there's just too many browsers, the best practice is to use feature detection with something like Modernizr.js – Antistrophenavigator.platform
is being deprecated: developer.mozilla.org/en-US/docs/Web/API/NavigatorID/platform – LeishauserAgent
. :-) It'snavigator.platform
that seems (very, very occasionally) useful. I also didn't say anything about doing browser detection. If you want to tell me how to feature-detect the OS, by all means, I'd be keen to know... :-) – Leishanavigator.platform
can also be spoofed trivially in firefox, in about:config, via the general.platform.override setting. I guessed at that name from the general.useragent.override setting. :-) ) – Leishanavigator
are deprecated, but neither the spec nor MDN indicates that the primary OS-related property,navigator.platform
, is in fact being deprecated. – Leisha