Skip to content

Instantly share code, notes, and snippets.

@vote539
Last active August 29, 2015 14:24
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 vote539/4d86883ffe9f22908bd0 to your computer and use it in GitHub Desktop.
Save vote539/4d86883ffe9f22908bd0 to your computer and use it in GitHub Desktop.
Tiny, lightweight function to detect Flexbox support.
// 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