The following should work. It may not be entirely optimized, though.
if (typeof jQuery == "undefined") {
var js = document.createElement("script");
js.setAttribute("src",...path to jquery...);
js.setAttribute("type","text/javascript");
document.head.appendChild(js);
//ditto for other files you mentioned
}
function isCSSLoaded(uri) {
var links = document.getElementsByTagName("link");
for (var i =0, len = links.length; i<len;++i) {
if (links[i].getAttribute("src") === uri) return true;
}
return false;
}
if (isCSSLoaded(...pathToYourCSSFile...) {
var css = document.createElement("link");
css.setAttribute("href",...path to css file...);
css.setAttribute("media","screen");
css.setAttribute("rel","stylesheet");
css.setAttribute("type","text/css");
document.head.appendChild(css);
//ditto for other files you mentioned
}
EDIT: note the above only applies to CSS loaded via links, and not those using @import