The example in this article describes the method of non-repeated import in js. Share it with everyone for your reference, the details are as follows:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>无标题页</title> <mce:script src="jquery-1.4.4.js" mce_src="jquery-1.4.4.js" type="text/javascript"></mce:script> <mce:script type="text/javascript"><!-- function importOnce(scriptPath) { var scripts = document.getElementsByTagName("script"); for (var index = 0; index < scripts.length; index++) { if (scripts[index].src.lastIndexOf(scriptPath) != -1) { return; } } var scriptTag = document.createElement("script"); scriptTag.type = "text/javascript"; scriptTag.src = scriptPath; var headTag = document.getElementsByTagName("head")[0]; headTag.appendChild(scriptTag); } importOnce("jquery-1.4.4.js"); importOnce("jquery-1.4.4.js"); importOnce("jquery-1.4.3.js"); importOnce("jquery-1.4.3.js"); // --></mce:script> </head> <body> </body> </html>
Readers who are interested in more JavaScript-related content can check out the special topics on this site: "Summary of JavaScript search algorithm techniques", "Summary of JavaScript animation special effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm techniques", "Summary of JavaScript traversal algorithms and techniques" and "JavaScript Mathematics Summary of operation usage》
I hope this article will be helpful to everyone in JavaScript programming.