Simple implementation of javascript file loading management, javascript Loading
This article describes the simple implementation of javascript file loading management. Share it with you for your reference. The details are as follows:
This section describes how to load and manage javascript files (modules,
Implement core functions of sea. js or require. js, with a line
<Script src = "js/light. js"> </script>
Load all js files.
// Load the js file on the webpage in the order of lightJs: 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.doc umentElement; 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 design javascript programs.