The other day there was a problem: by all means, you had to distinguish iPad1 from iPad2 in the browser. iPad3 can be distinguished using window.devicePixelRatio, but with the first two problems. A detailed study of the entire window object did not give any results. There was a thought to try to distinguish them on the video card using WebGL, but WebGL is blocked.
It was decided to try to load percent. The following code gave a very funny result.
var rad = 37.5 * (Math.PI / 180), width = 11.32424654356, z, cache, time = new Date().getTime(); for (z = 150000; z-- ;){ cache = width * z * Math.sin(rad) + width * z * Math.cos(rad); } console.log(new Date().getTime() - time);
On iPad1, the result is stable: ≈113–118ms, and in the case of heavy workload it will only be more.
On iPad2, the result is stable: ≈60ms and in case of heavy workload there will only be more.
I propose to consider 100ms as a barrier to determining the version, and run this test when you first load the application, recording the result in localStorage.
PS: Of course, the code needs to be combed, but the message is important here.
')
upd :
Crystall offered a great solution . Thank!