Skip to content

Instantly share code, notes, and snippets.

@addyosmani
Created June 7, 2011 13:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addyosmani/1012214 to your computer and use it in GitHub Desktop.
Save addyosmani/1012214 to your computer and use it in GitHub Desktop.
Compact browser prefix checking
/* 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")
@SlexAxton
Copy link

Modernizr.prefixed() BAM

@addyosmani
Copy link
Author

Dayum.

That's sexy, Slexy. Reading up on Modernizr _prefixes and _domPrefixes nao.

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