Skip to content

Instantly share code, notes, and snippets.

@csuwildcat
Last active August 29, 2015 13:57
Show Gist options
  • Select an option

  • Save csuwildcat/9709238 to your computer and use it in GitHub Desktop.

Select an option

Save csuwildcat/9709238 to your computer and use it in GitHub Desktop.
User's browser prefix detection
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1];
return {
dom: pre == 'ms' ? 'MS' : pre,
lowercase: pre,
css: '-' + pre + '-',
js: pre == 'ms' ? pre : pre[0].toUpperCase() + pre.substr(1)
};
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment