Skip to content

Instantly share code, notes, and snippets.

@aarongustafson
Last active May 12, 2019 11:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarongustafson/081d6e950c1f2cc57e22 to your computer and use it in GitHub Desktop.
Save aarongustafson/081d6e950c1f2cc57e22 to your computer and use it in GitHub Desktop.
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