This article illustrates the simple implementation method of JavaScript file loading management. Share to everyone for your reference. Specifically as follows:
Here is a super simple load management for JavaScript files (modules).
Implement Sea.js or Require.js core functions, with one line
<script src= "Js/light/light.js" ></script>
Load all the JS files.
In the order of Lightjs, let the page load JS file:
var lightjs = [
"./js/light/pre/jquery-1.8.0.min.js",
"./js/light/pre/ Jquery-lib.js ",
"./js/light/pre/less-1.4.2.min.js ",
"./js/lihgt/pre/util.js ",
"./js/xla.js ",
" ./js/light/light_file.js "
];
var light;
if (!light)
light = {};
Light.load = (function (LIGHTJS) {
if (!lightjs)
Lightjs = [];
var doc = document;
var head = Doc.head | | Doc.getelementsbytagname ("Head") [0] | | doc.documentelement;
for (var i = 0; i < lightjs.length i++) {
var path = lightjs[i];
var node = doc.createelement ("script");
Node.charset = "Utf-8";
NODE.SRC = path;
Head.appendchild (node);
}
return doc;
} (Lightjs));
I hope this article will help you with your JavaScript programming.