Microsoft Edge – don’t do browser detection
This article is part of a series of posts detailing specific compatibility tollgates for a modern web, and how you can take action to make sure your site works as intended in the world of modern web browsers:
- EdgeHTML interoperability
- Legacy plug-ins & features
- Frameworks & Libraries
- Browser detection (this post)
- CSS prefixes
Don’t do browser detection
Browser Detection is a technique to determine how the webpage should render across many different versions of browsers. In a script this would mean using code like navigator.userAgent to act differently depending on what User Agent string is supplied to the page. Every browser you’re using has a User Agent string that contains information about the browser. Only problem with that “unique” string is that since way back they’ve more or less imitated each other, and today they hold (pretty much) the same information. It is not a reliable way of determining if a feature is supported or not. Simply put – User Agents can’t be trusted.
Why is it important?
Your users will get their best experience in their preferred browser. You can spend less time maintaining separate code bases for various modern browsers including Microsoft Edge.
What will we look for?
We check if the webpage may be using browser detection techniques to determine how the webpage should render across many different versions of browsers, like browser.userAgent.
How can you fix it?
Where can you learn more?
- Read more on what’s different about the Microsoft Edge UA string
- View list of unsupported features in Microsoft Edge including conditional comments
- View list of upcoming web platform status by feature in Microsoft Edge
- Learn feature detection
- Implement feature detection with Modernizr
- Understand what features are available in what browser using CanIUse.com
- jQuery on Browser Detection (bad) vs Feature Detection (good)
- History of the Browser User Agent string