Home >Web Front-end >JS Tutorial >Introduction to several ways to include js files_javascript skills

Introduction to several ways to include js files_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:34:571005browse

1. Direct quotation from the page

Copy code The code is as follows:




2. Dynamically write to the page

Copy code The code is as follows:

document.write('')
document.write('')

3. Simulate the included function

Copy code The code is as follows:

function include(path){
var a=document.createElement("script");
a.type = "text/javascript";
a.src=path;
var head=document.getElementsByTagName("head")[0];
head.appendChild(a);
}

include("a.js")

include("b.js")

4.js modular programming

Require.js methods

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn