Including JavaScript and CSS on the page (jQuery)

I recently met the includeMany jQuery plugin to include external JavaScript and CSS pages in a page. Although it was released in early 2009, there are no links to blogs or other places. I wonder if this can be used? What is the usage experience?

+3
source share
2 answers

You can enable JavaScript and CSS using the example below. No plugins needed.

To enable JavaScript code, do the following:

$.getScript("youpathtoscript.js",function() {
            //this script is loaded
});

To include CSS files:

$("<link/>", {
   rel: "stylesheet",
   type: "text/css",
   href: "styles/yourcss.css"
}).appendTo("head");
+5
source

To collect CSS / JavaScript imports (including):

Alternative alternative:

$("<script></script>", {type: "text/javascript",})
.text("alert('your function');")
.appendTo("head");

Inline CSS:

$("<style></style>", {type: "text/css",})
.text("#you{css:rule}")
.appendTo("head");
0

Source: https://habr.com/ru/post/1746738/


All Articles