How to detect each capability instead of guessing from a user agent — with the check, why the browser name fails, and what to do when it is absent.
18 capabilities
Each entry gives the check, why guessing from the browser name fails, and what to do when the check fails.
All Chromium. A check on the browser name treats them as four cases that behave identically, and misses the fifth that claims to be Safari.
A user agent is a request header. Extensions rewrite it, privacy tools randomise it, and bots copy whatever they like.
A matrix baked into code is wrong within months and nothing reports it. A capability check is correct in every browser, including the ones released after you wrote it.
Testing for a constructor and then calling a method added three versions later still throws. The test passed; the code broke anyway.
A detection with no answer for the failing case produces a silently broken page on exactly the browsers that failed it.
navigator.maxTouchPoints > 0Why not the browser name: Checking the user agent for "Mobile" misses every touchscreen laptop and every iPad, which reports itself as a Macintosh. It also wrongly includes a phone connected to a mouse.
When it fails: Assume no touch and keep hit targets large enough for both, which is better for everyone.
window.matchMedia('(hover: hover)').matchesWhy not the browser name: A device can have both touch and a mouse. Asking whether hovering is possible answers the question that matters for a hover-revealed control, which no device check does.
When it fails: Make the content reachable without hover: on tap, on focus, or always visible.
window.matchMedia('(pointer: coarse)').matchesWhy not the browser name: This is what decides hit target size, and it is about the pointer rather than the device.
When it fails: Use the larger target size.
window.matchMedia('(prefers-reduced-motion: reduce)').matchesWhy not the browser name: This is a stated accessibility preference, not a device characteristic. Nothing in a user agent carries it.
When it fails: Animate. The absence of the preference is the default, not an unknown.
Use <picture> with <source type="image/avif"> and let the browser chooseWhy not the browser name: The browser already knows which formats it decodes. Choosing in JavaScript means waiting for JavaScript, and choosing on the server from a user agent means maintaining a table that goes stale.
When it fails: The <img> inside <picture> is the fallback, and it is used automatically. Accept header negotiation works server-side for the same reason.
await createImageBitmap(blob).then(() => true, () => false)Why not the browser name: Decoding a one-pixel sample is a real test. A version table is a guess.
When it fails: Serve the widely supported format.
CSS.supports('selector(:has(a))') or CSS.supports('backdrop-filter', 'blur(4px)')Why not the browser name: CSS.supports asks the engine the exact question. A version check asks a proxy for it, and gets the answer wrong for every forked browser and every flag.
When it fails: Use @supports in the stylesheet itself, which needs no JavaScript at all.
CSS.supports('container-type', 'inline-size')Why not the browser name: Support arrived at different times in each engine and is not predictable from a browser name.
When it fails: Fall back to a media query on the viewport, which is coarser but always available.
'IntersectionObserver' in windowWhy not the browser name: A property check asks the browser directly and costs nothing. A version table has to be maintained, goes stale silently, and is wrong for every forked browser — and the answer was never about the browser's name in the first place.
When it fails: A scroll listener with throttling, or native loading="lazy" for images.
'startViewTransition' in documentWhy not the browser name: The API is new and arriving at different times. The name is either there or it is not.
When it fails: Navigate without a transition, which is what every browser did until recently.
navigator.clipboard && 'writeText' in navigator.clipboardWhy not the browser name: The API also requires a secure context and, in some browsers, a user gesture — so even where it exists the call can reject. The check tells you whether to try, not whether it will succeed.
When it fails: Catch the rejection and show the text selected so it can be copied manually. Never assume the write succeeded.
'share' in navigator && navigator.canShare?.({ files })Why not the browser name: Whether sharing works depends on what is being shared, which is why canShare exists. A bare presence check passes and then the call fails on files.
When it fails: Show your own share options: a copy-link button and direct links.
await navigator.userAgentData?.getHighEntropyValues(['platformVersion', 'model'])Why not the browser name: Chromium only, asynchronous, and the values may be withheld. It is the right way to ask when you genuinely need the platform version, which is rare.
When it fails: Do without. The question that needed the platform version almost always has a feature check behind it.
window.isSecureContextWhy not the browser name: Many APIs exist but refuse to work outside a secure context, so a presence check passes and the call fails. This explains why.
When it fails: Say plainly that the feature needs HTTPS rather than failing silently.
A try/catch around a test write, not just 'localStorage' in windowWhy not the browser name: The property exists in private browsing and with site data blocked, and then throws on write. Checking for the name alone is the single most common cause of a page that works for you and crashes for someone else.
When it fails: Keep the value in memory for the session and carry on.
navigator.storage?.estimateWhy not the browser name: The figure is deliberately imprecise, so treat it as an order of magnitude.
When it fails: Write defensively and handle a quota error wherever you write.
navigator.connection?.saveData === trueWhy not the browser name: This is the only reliable member of the Network Information API, and it is a stated preference.
When it fails: Serve your normal experience.
navigator.connection?.effectiveTypeWhy not the browser name: Available in Chromium only, and it describes a recent average rather than the present moment — a connection reported as 4g can still be unusable.
When it fails: Measure what you actually care about: time your own first request and adapt from that. It works everywhere and describes the real connection.
A capability check answers whether the thing exists, not whether it works correctly. Several browsers have shipped an API that was present and subtly wrong, and no detection can find that — only testing the behaviour in that browser can. Keep the fallback path working rather than deleting it once the check starts passing.
Feature Detection Reference runs entirely on your device — this is a reference, so nothing is detected about your own browser and nothing is sent.
You’re on the Free plan. Compare plans
This is deliberately not a support matrix. A table of which browser version added which feature is wrong within months and stays wrong silently, because nothing in the page tells the reader it has gone stale. More importantly, the right answer never depended on the browser's name: it depends on whether the thing is there, which the browser can be asked directly.
Every entry says why the obvious alternative is wrong. "Use CSS.supports" is advice. "Checking the browser name fails because four different browsers share one engine and a fifth lies about being Safari" is a reason, and a reason is what survives being forgotten.
A fallback is part of the detection. A check with no answer for the failing case is an if with an empty else, which is how a feature test becomes a silently broken page on the browsers that failed it — and you should check the capability you will actually use, because testing for a constructor and then calling a method added three versions later still throws.
Because it is wrong within months and nothing reports that it has gone stale. A capability check is correct in every browser including the ones released after you wrote it, and the browser's name was never what actually mattered.
For statistics, and for working around a specific known bug in a specific version where no capability check can distinguish the broken behaviour. Both are narrow. For deciding whether to use a feature, the capability is the right question.
Because a constructor existing does not mean every method on it does. Testing for the constructor and then calling a method added three versions later throws at runtime — the test passed and the code broke anyway.
No. It tells you the feature exists. Several browsers have shipped an API that was present and subtly wrong, and no detection finds that — only testing the behaviour in that browser does. Keep the fallback working rather than deleting it once the check starts passing.
No. It is a reference: a list of checks to use in your own code. Nothing about your browser is inspected or sent.
If a tool here saved you some time, you can put something towards the hosting.Buy me a coffee, on Ko-fi, opens in a new tab