6 examples of 'javascript include library' in JavaScript

Every line of 'javascript include library' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
3function include(script) {
4 jstestdriver.console.log("include called");
5 document.write("<script type=\"text/javascript\" src=\"" + script + "\"></script>");
6}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

7function include_js(name) {
8 document.writeln('<scr'+'ipt src="'+ RIGHTJS_GOODS_ROOT + name +'.js"></scr'+'ipt>');
9}
37function IncludeJavaScript(jsFile)
38{
39 var oHead = document.getElementsByTagName('head')[0];
40 var oScript = document.createElement('script');
41 oScript.type = 'text/javascript';
42 oScript.charset = 'utf-8';
43 oScript.src = jsFile;
44 oHead.appendChild(oScript);
45};
3function include(path, sandbox) {
4 var
5 vm = require("vm"),
6 fs = require("fs"),
7 file;
8
9 file = fs.readFileSync(path);
10 vm.runInNewContext(file, sandbox);
11}
1function include(paths, callback) {
2 var paths = typeof paths == "object" ? paths : [paths];
3 var loadCount = 0;
4
5 for (var i = 0, l = paths.length; i < l; i++) {
6 var script = document.createElement("script");
7 script.setAttribute("type", "text/javascript");
8 script.setAttribute("src", paths[i]);
9 document.getElementsByTagName("head")[0].appendChild(script);
10
11 script.onload = function() {
12 loadCount++;
13 if (loadCount == l) { callback(); }
14 };
15 }
16}
61function generate_includes(includes, library) {
62 library = library || [];
63 var code = "";
64 var i;
65 if (library.length) {
66 code += "var __lib__ = SCRIPTOR." + grunt.config('meta.user') + ".lib();\n";
67 for (i in library) {
68 code += "var " + library[i] + " = __lib__." + library[i] + ";\n";
69 }
70 }
71 for (i in includes) {
72 var file = includes[i];
73 var tmp = grunt.file.read("include/" + file + ".js");
74 tmp = tmp.replace(/.*INCLUDE\(\w+\).*/g, "");
75 code += "var " + file + " = " + tmp + ";\n";
76 }
77 return code;
78}

Related snippets