What's the best way to determine at runtime if a browser is too slow to gracefully handle complex JavaScript/CSS?

前端 未结 6 2170
挽巷
挽巷 2020-12-25 11:55

I\'m toying with the idea of progressively enabling/disabling JavaScript (and CSS) effects on a page - depending on how fast/slow the browser seems to be.

I\'m speci

6条回答
  •  有刺的猬
    2020-12-25 12:21

    Take a look at some of Google's (copyrighted!) benchmarks for V8:

    • http://v8.googlecode.com/svn/data/benchmarks/v4/regexp.js

    • http://v8.googlecode.com/svn/data/benchmarks/v4/splay.js

    I chose a couple of the simpler ones to give an idea of similar benchmarks you could create yourself to test feature sets. As long as you keep the run-time of your tests between time logged at start to time logged at completion to less than 100 ms on the slowest systems (which these Google tests are vastly greater than) you should get the information you need without being detrimental to user experience. While the Google benchmarks care at a granularity between the faster systems, you don't. All that you need to know is which systems take longer than XX ms to complete.

    Things you could test are regular expression operations (similar to the above), string concatenation, page scrolling, anything that causes a browser repaint or reflow, etc.

提交回复
热议问题