if (window.performance && window.performance.timing) { var download_time = (window.performance.timing.responseEnd - window.performance.timing.responseStart); var speed = ($('html').html().length) / download_time; if (speed < 400) { alert('slow'); } else { alert('fast'); } }
Note that this works best it the page size is large. For small pages the TCP/IP overhead for is large compared to your download time. My page was about 19304 bytes and I was able to detect mobile vs desktop.
Also see this stackoverflow question.
This does not work for IE8 and Safari
Keine Kommentare:
Kommentar veröffentlichen