Created
June 7, 2011 13:14
-
-
Save addyosmani/1012214 to your computer and use it in GitHub Desktop.
Compact browser prefix checking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* GPL */ | |
/*Whitelist version with quick test*/ | |
function k(q){ | |
var s, | |
d = document.createElement("div"), | |
n = q, | |
p = [ "webkit", "moz", "ms", "O", "" ], | |
o = n, | |
r, j=0, len, l; | |
for(;l=p[j];j++) { | |
l = p[ j ]; | |
r = l + n; | |
if ( r in d.style ) { | |
break; | |
} | |
} | |
return l; | |
}; | |
console.log(k('Transform')); | |
/*Packed version - 180 characters*/ | |
function k(q){var s,d=document.createElement("div"),n=q,p=["webkit","moz","ms","O",""],o=n,r,j,len,l;for(j=0,len=p.length;j<len;j++){l=p[j];r=l+n;if(r in d.style){break}}return l}; | |
/*Work in progress based on some previous @140bytes tweets */ | |
function(a,b){$=a["r"+b]||a["webkitT"+b]||a["mozT"+b]||a["msT"+b]||a["oT"+b]||function(a){setTimeout(a,15)}}(this,"ransform") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dayum.
That's sexy, Slexy. Reading up on Modernizr _prefixes and _domPrefixes nao.