Search code examples
javascripthtmlbrowserhardware-accelerationmodernizr

Is it possible to detect hardware acceleration by browser in JavaScript?


I've noticed that font sizes are not the same across browsers which use hardware acceleration due to the font rendering changes - making characters appear smaller. On sites with horizontal navigation, this is actually becoming an issue.

Is it possible to use JavaScript or a JS library to detect hardware acceleration as being enabled (or disabled) in the browser?

Modernizr doesn't seem to offer this choice.


Solution

  • The font rendering differs depending on browser, OS and user settings. So your website should deal with such differences gracefully instead of relying on pixel exact font rendering. Hardware acceleration is just one more source of such differences.

    Since you're not actually interested in finding out if it is hardware accelerated, but in differences in font rendering how about measuring the size some rendered text has, and adapt your page based on that?