Why not measure the time that the browser takes to compute something complex, similar to what you want to do, and set a threshold time for it?
function detectBrowserSpeed(){ var i, slowThreshold = 100; // milliseconds startMillis = + new Date(); //The + is to 'force' casting to an integer representing EPOCH milliseconds. If + is ommited, then I get an instance of Date. //Do something complex here: for (i=0;i<100000;i+=0.1){ } var elapsed = (+ new Date()) - startMillis; if(elapsed > slowThreshold){ return 'slow'; }else{ return 'fast'; } }
source share