Skip to main content
add note about library use
Source Link
Lazerbeak12345
  • 498
  • 1
  • 6
  • 23

Perhaps the real answer is that 90% of the time, you can't reliably detect any specific browser.

The most reliable way for your use case is to provide a download button for each browser and let the user - who knows for certain what browser they are on "tell you." All of the detection methods shown in these other answers will either eventually stop working, or can easily be faked.

User-agent strings can be overridden by the user.

Browsers, over time, trend toward removing unique API differences. (Source: look at Internet Explorer over the years)

If you must use browser detection, use a well-updated library to do so. So long as you keep that library up-to-date, you can be assured that the detection will not fail - so long as it's not too reliant upon UA strings.


For other use cases, don't use browser detection - use feature detection. Modern Firefox supports everything - if not more - that Chrome does, and generally is closer to the w3 & etc. specs. A tool called "browserlist" is a great tool to determine which browsers' features your code should use. Tools like Webpack, Parcel, Babel, and more use this - so you can use the latest browser features without having to write the compatibility code yourself.

Perhaps the real answer is that 90% of the time, you can't reliably detect any specific browser.

The most reliable way for your use case is to provide a download button for each browser and let the user - who knows for certain what browser they are on "tell you." All of the detection methods shown in these other answers will either eventually stop working, or can easily be faked.

User-agent strings can be overridden by the user.

Browsers, over time, trend toward removing unique API differences. (Source: look at Internet Explorer over the years)


For other use cases, don't use browser detection - use feature detection. Modern Firefox supports everything - if not more - that Chrome does, and generally is closer to the w3 & etc. specs. A tool called "browserlist" is a great tool to determine which browsers' features your code should use. Tools like Webpack, Parcel, Babel, and more use this - so you can use the latest browser features without having to write the compatibility code yourself.

Perhaps the real answer is that 90% of the time, you can't reliably detect any specific browser.

The most reliable way for your use case is to provide a download button for each browser and let the user - who knows for certain what browser they are on "tell you." All of the detection methods shown in these other answers will either eventually stop working, or can easily be faked.

User-agent strings can be overridden by the user.

Browsers, over time, trend toward removing unique API differences. (Source: look at Internet Explorer over the years)

If you must use browser detection, use a well-updated library to do so. So long as you keep that library up-to-date, you can be assured that the detection will not fail - so long as it's not too reliant upon UA strings.


For other use cases, don't use browser detection - use feature detection. Modern Firefox supports everything - if not more - that Chrome does, and generally is closer to the w3 & etc. specs. A tool called "browserlist" is a great tool to determine which browsers' features your code should use. Tools like Webpack, Parcel, Babel, and more use this - so you can use the latest browser features without having to write the compatibility code yourself.

Source Link
Lazerbeak12345
  • 498
  • 1
  • 6
  • 23

Perhaps the real answer is that 90% of the time, you can't reliably detect any specific browser.

The most reliable way for your use case is to provide a download button for each browser and let the user - who knows for certain what browser they are on "tell you." All of the detection methods shown in these other answers will either eventually stop working, or can easily be faked.

User-agent strings can be overridden by the user.

Browsers, over time, trend toward removing unique API differences. (Source: look at Internet Explorer over the years)


For other use cases, don't use browser detection - use feature detection. Modern Firefox supports everything - if not more - that Chrome does, and generally is closer to the w3 & etc. specs. A tool called "browserlist" is a great tool to determine which browsers' features your code should use. Tools like Webpack, Parcel, Babel, and more use this - so you can use the latest browser features without having to write the compatibility code yourself.