Create a gist now

Instantly share code, notes, and snippets.

A simple way to remove Bootstrap’s formatting and JavaScript influence
(function(){
var body = document.body,
css = document.querySelectorAll('[href*=bootstrap][href$=css]'),
css_len = css.length,
js = document.querySelectorAll('[src*=bootstrap][src$=js]'),
js_len = js.length,
xhr = new XMLHttpRequest(),
strapped = false;
// Found Bootstrap CSS
if ( css_len ) {
// removing the CSS is easy
while ( css_len-- ) {
css[css_len].parentNode.removeChild(css[css_len]);
}
}
// Found Bootstrap JS
if ( js_len ) {
// resetting the HTML is more difficult
xhr.onload = function(){
var new_body = this.responseXML.body;
// remove the scripts
while ( js_len-- ) {
js[js_len].parentNode.removeChild(js[js_len]);
}
body.parentNode.replaceChild( new_body, body );
}
xhr.open('GET', window.location.href, true);
xhr.responseType = 'document';
xhr.send();
}
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment