“Option 2: User Agent Sniffing” doesn’t have to use the same URL for both scripts. Use different URLs, and make the HTML (likely not cached as aggressively anyhow) differential. This gets rid of one of the issues you describe.
-
-
Replying to @mathias
Ah yeah, so just using UA sniffing to correct for browsers that request the wrong script?
2 replies 0 retweets 1 like -
Replying to @_developit
Not even that. Just if (IS_MODERN_UA) { <script type=module src=modern.mjs></script> } else { <script src=legacy.js></script> } Also, it's ok if IS_MODERN_UA doesn't catch every possible UA string that supports modules, as the fallback still works.
3 replies 0 retweets 17 likes -
Replying to @mathias @_developit
That is, the simplest possible implementation would simply match a hardcoded set of UA strings, and nothing else. You don't need to handle every possible edge case. There's nothing inherently wrong with UA sniffing if it's used as progressive enhancement in this manner.
4 replies 0 retweets 5 likes -
Replying to @mathias @_developit
(As opposed to say, completely blocking website access based on the UA string. Boo to that!)
1 reply 0 retweets 6 likes -
Replying to @mathias @_developit
Also, if you're just sniffing for JS engine level, UA sniffing can be done pretty concisely and generally. Something like the following:https://gist.github.com/domenic/534c1da00ae7d0ed780d3f3d715d4466 …
2 replies 0 retweets 9 likes -
Let's not encourage more UA sniffing than we already have out there...
1 reply 0 retweets 1 like -
Replying to @yoavweiss @domenic and
If it's done tightly (that is, exact matches), it can be done well. Not many folks doing that, but I've outlined how to do it well with good fallbacks many times over the past decade.
2 replies 0 retweets 1 like -
Replying to @slightlylate @yoavweiss and
I agree. In particular, User-Agent sniffing is great as long as your rule for unknown agents can safely be the same as your preferred path, which means that you are specifically making rules to catch a known set of old agents, whose number will only dwindle over time, not grow.
1 reply 0 retweets 2 likes -
Replying to @FremyCompany @slightlylate and
if (navigator.appVersion > 11)
2 replies 0 retweets 4 likes
My proposal has always been UA as (close-to) hash backed by polyfill fallback. This gets you best of both.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
& Web Standards TL; Blink API OWNER
Named PWAs w/
DMs open. Tweets my own; press@google.com for official comms.