Last active
August 29, 2015 14:24
-
-
Save vote539/4d86883ffe9f22908bd0 to your computer and use it in GitHub Desktop.
Tiny, lightweight function to detect Flexbox support.
This file contains hidden or 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
// Expanded | |
var flexboxSupported = (function(){ | |
var prop = "flex-basis:1px"; | |
var el = document.createElement("div"); | |
var prefixes = ["", "-webkit-", "-moz-", "-o-", "-ms-"]; | |
for(var i=0; i<prefixes.length; i++){ | |
el.style.cssText += prefixes[i]+prop; | |
if(!!el.style.length) return true; | |
} | |
return false; | |
})(); | |
// Compressed | |
var flexboxSupported = (function(){for(var b=document.createElement("div"),d=["","-webkit-","-moz-","-o-","-ms-"],c=0;5>c;c++)if(b.style.cssText+=d[c]+"flex-basis:1px",b.style.length)return!0;return!1})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment