Strip CSS in JavaScript 1.6+ browsers (Firefox 1.5+, IE9+, Opera 7+, WebKit 533+)


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. Array.prototype.slice.call(document.all || document.getElementsByTagName('*')).forEach(function (el) {
  2. if (/style/i.test(el.nodeName) || (/link/i.test(el.nodeName) && 'stylesheet' === el.getAttribute('rel'))) {
  3. el.parentNode.removeChild(el);
  4. }
  5. else if (null !== el.getAttribute('style')) {
  6. el.removeAttribute('style');
  7. }
  8. });

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.