Search code examples
jquerycssvendor-prefix

jquery css() auto vendor prefixes not working?


I've read in several places that jquery 1.6 and onwards apply vendor prefixes automatically when using the css() method. I'm using Jquery 1.11.1 and it appears to do no such thing.

If I call:

$(div).css({transform:"scale(2)"});

and check on Chrome developer tools' style inspector, it shows exactly that: "transform: scale(2);" No vendor prefixes.

Why is this and should I add the various vendor prefixes myself?


Solution

  • jQuery will add the prefix for you, but only if the browser actually requires it. Chrome hasn't needed prefixes on transforms for a while (as of version 36, to be precise), so jQuery doesn't bother.

    This check is made in line 6436:

    function vendorPropName( style, name ) {
    
        // shortcut for names that are not vendor prefixed
        if ( name in style ) {
            return name;
        }
    
        // ...