Return to Snippet

Revision: 35326
at November 5, 2010 09:28 by danbeam


Updated Code
Array.prototype.slice.call(document.all || document.getElementsByTagName('*')).forEach(function (el) {
    if (/style/i.test(el.nodeName) || (/link/i.test(el.nodeName) && 'stylesheet' === el.getAttribute('rel'))) {
        el.parentNode.removeChild(el);
    }
    else if (null !== el.getAttribute('style')) {
        el.removeAttribute('style');
    }
});

Revision: 35325
at November 5, 2010 09:21 by danbeam


Initial Code
Array.prototype.slice.call(document.all || document.getElementsByTagName('*')).forEach(function (el) {
    if (/style/i.test(el.nodeName) || (/link/i.test(el.nodeName) && 'stylesheet' === el.getAttribute('rel'))) {
        el.parentNode.removeChild(el);
    }
    else if (el.getAttribute('style')) {
        el.removeAttribute('style');
    }
});

Initial URL

                                

Initial Description

                                

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

Initial Tags
css, javascript

Initial Language
JavaScript