Subpixel Layout Support Test

Test to see if browser supports using subpixel layouts.

by Aubrey Taylor

JavaScript

exports = {};
exports.subpixels = _.memoize(function(){
    // memoize will cache the result of this test
    console.log('ran');
    
    var el, body, width, rect;

    width = 1.5;
    el    = document.createElement('div');
    body  = document.body;

    el.style.width = width + "px";
    body.appendChild(el);

    rect = el.getBoundingClientRect();

    return width == rect.width;
});

console.log(exports.subpixels());

// run again to verify result is memoized
console.log(exports.subpixels());