jquery - javascript load css but keep current style -


i have following code run after page loads:

function prepare_bootstrap() {     console.log("preparing bootstrap...");     var items = document.body.getelementsbytagname("*");     (var = items.length; i--;)     {         items[i].style.csstext = '!important';     }       var style1 = document.createelement("link");     style1.rel = "stylesheet";     style1.href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css";     document.body.appendchild(style1);      var style2 = document.createelement("link");     style2.rel = "stylesheet";     style2.href = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap-theme.min.css";     document.body.appendchild(style2);      var script = document.createelement("script");     script.src = "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js";     script.onload = script.onreadystatechange = function()     {         if (!this.readystate || this.readystate == "loaded" || this.readystate == "complete")         {             prepare_bootstrapdialog();         }     };     document.body.appendchild(script); } 

i loading bootstrap allow nicely formatted popups. however, bootstrap overrides everything, making page messed up. tried making every style important, honest, have no idea i'm doing.

is there way make css not override previous css? thanks!

edit: before stated, impossible load bootstrap first javascript part of bookmarklet.

have read of this:

https://developer.mozilla.org/en-us/docs/web/html/element/style#a_scoped_stylesheet

will work in browsers though, not option publicly facing site. best way not include bootstrap in entirety, instead picking out bits need , using them. can custom builds of bootstrap here:

http://getbootstrap.com/customize/

you shouldn't load css styles aren't actively using. doing creates more debugging work if encounter styling issues, , means you're potentially wasting bandwidth.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -