Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
vendorPrefixr

Adds vendor prefix when needed.

Thanks to Evghenusi for minification tips

function(
a, //(string) property to vendor-prefixize
b,c,d //placeholders
)
{
for(b in c=["Moz","Webkit","Ms","O"]) //for every prefix
if((d=c[b]+
a[0].toUpperCase()+a.slice(1) //capitalize property
) in (new Image).style) //check if the prefixed property is an object of (new Image).style
a=d; //set variable: a to the prefixed poperty
return a //return the prefixed property, else return the unprefixed property
}
function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a}
{
"name": "vendorPrefixr",
"description": "Adds vendor prefix when needed",
"keywords": [
"css",
"dom",
"style",
"vendor",
"prefix"
]
}
<!DOCTYPE html>
<script>
vendorPrefixr = function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a}
document.write(vendorPrefixr("transition"))
</script>

function(a,b,c,d){for(b in c=["Moz","Webkit","Ms","O"])if((d=c[b]+a[0].toUpperCase()+a.slice(1))in(new Image).style)a=d;return a} ?

Owner

williammalo commented Mar 25, 2012

@Evghenusi

Smart!
I updated my code to match yours!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment