4 ms·
To clarify, I didn't mean don't check if the feature you want to use exists on the user's browser. I meant don't come to that conclusion using User-Agent string
by OkayPhysicist 1y ago
To clarify, I didn't mean don't check if the feature you want to use exists on the user's browser. I meant don't come to that conclusion using User-Agent strings. JavaScript makes if very easy to check if a method you want to use exists or not: just check if the function is undefined.
If you do it the right way, if/when another browser implements the feature you used, suddenly you support that browser, with no code changes. If you check UAs, then you need to keep tabs on browser updates and manually update your website when features get added to browsers, and you need to check what version people are using because maybe it's out of date, it's a whole thing.
What drives me nuts is that the right way is the easy way.
- cosmic_cheese 1y agoWe’re in full agreement here, all I was saying is that the menality that leads to user agent sniffing is likely the idea that engines that aren't Blink are so incapable and will break the site/app so badly that it’s better to just rule out their usage altogether. Checking on a per-function basis (or alternatively, just not insisting on using bleeding edge features in the first place) is absolutely the way to go about avoiding brokeness.