Detecting if the browser is enough for the site

Function detection is usually preferable to browning. What should I do if certain browsers "support" the functions that I use but have javascript for too long?

I use the d3 library for some complex visualizations. The rendering is very smooth in chrome / firefox, acceptable in IE9, and slow in IE8. I would like to show a banner for IE8 users who inform them of an update and banner notification to IE9 users that it will be faster in chrome or FF. Is it wrong to do this with a sniffing user agent?

+4
source share
1 answer

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'; } } 
+2
source

All Articles