Instantly share code, notes, and snippets.

What would you like to do?
Simple function to determine whether a given CSS property is supported or not. Useful for conditional execution of JS animations, rounded corners, etc.
// Is the passed CSS property supported?
// eg. detectCSS('transition')
function detectCSS(prop){
prop = prop.replace(/-(\w)/g,function(s,g){return g.toUpperCase()}),
pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i){
prop = prop.slice(0,1).toUpperCase() + prop.slice(1);
if(pre[i] + prop in
return true;
return false;

This comment has been minimized.


barneycarroll commented Jan 16, 2012

Dropped hyphenated notation in favour of camelcase notation for vendor-prefixed property detection, so it works in FF again.

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