Hacker News new | ask | show | jobs
by BinaryIdiot 3816 days ago
I'd have to look at the code but you can detect just about anything within the browser; do the check once regarding what features you want to use, store and do that. User agent string parsing is a hack that's typically easier to do hence why so many still rely on it.

Having said that I don't think they'd be all ears; their code isn't opened source and while I could try to debug through their minified code that hardly seems worth it for me to do.

1 comments

Devil's advocate:

Detecting the features available in the browser is potentially two requests: the server sends HTML/JS to the client, the client makes a decision, and then requests more data that's compatible with its feature set. If the server can do feature detection by user agent sniffing, it's potentially one request.

The client has to do this for every browser session, too, since browsers are frequently upgraded and the features change week-to-week.

> Detecting the features available in the browser is potentially two requests: the server sends HTML/JS to the client, the client makes a decision, and then requests more data that's compatible with its feature set. If the server can do feature detection by user agent sniffing, it's potentially one request.

That's not really true though. The code that's going to load the video will be downloaded and then the code will request the video. So those two requests happen no matter what. Cache the feature detection so it's slightly faster after the first time.

> The client has to do this for every browser session, too, since browsers are frequently upgraded and the features change week-to-week.

Browsers are unlikely to lose the ability to use whatever codec you think is best so I think this is a safe assumption. Bonus points if you can detect its failure and re-run the feature detection in case something odd like that would happen.