Posted By

danbeam on 11/05/10


Tagged

css javascript strip manipulation


Versions (?)

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


 / Published in: JavaScript
 

  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  

You need to login to post a comment.