Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

1. Pick the API that's most likely to be the fastest (based on marketshare) as the default to use.

2. Use `setInterval` to start your benchmark routine.

3. Benchmark function runs the API using a simple loop that will return quickly (i.e. within 2ms) using performance.now to evaluate.

4. When you obtain enough samples to indicate an alternate path is faster disable the benchmark function

No freezing the browser. Shouldn't take too long to switch to an optimized version.

That being said, this is a lot of complexity / hard to implement in a robust and fast way so I'm not saying it's a better answer.



Yeah or just test the user agent.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: