In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you what JavaScript's file and module loader requirejs is like, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
Requirejs is a very small JavaScript module loading framework and is one of the best implementers of the AMD specification. It is ideal for use in browsers, but it can also be used in other scripting environments, like RhinoandNode. Loading modular scripts with Requirejs will improve the loading speed and quality of the code.
Requirejs advantages:
1. Realize the asynchronous loading of js files to avoid losing response of web pages.
2. Manage the dependence between modules to facilitate the writing and maintenance of the code.
3. Based on the AMD modularization mechanism, the front-end code can also be modularized.
Requirejs usage
For example, your project has a project.html page and some scripts, with a directory layout as follows:
Project directory /
Project.html
Scripts/
Main.js
Require.js
Helper/
Util.js
In order to take full advantage of the optimization tool, it is recommended that you put all the scripts outside the html, and then only reference require.js to request to load your other scripts:
MySampleProject
MySampleProject
In main.js, you can use require () to load all the scripts you need to run. This ensures that all your scripts is loaded here
Require (["helper/util"], function (util) {
/ / Thisfunctioniscalledwhenscripts/helper/util.jsisloaded.
/ / Ifutil.jscallsdefine (), thenthisfunctionisnotfireduntil
/ / util'sdependencieshaveloaded,andtheutilargumentwillhold
/ / themodulevaluefor "helper/util".
})
The above is what JavaScript's file and module loader requirejs looks like. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.