Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[js] 第85天 js延迟加载的方式有哪些? #594

Open
haizhilin2013 opened this issue Jul 9, 2019 · 6 comments
Open

[js] 第85天 js延迟加载的方式有哪些? #594

haizhilin2013 opened this issue Jul 9, 2019 · 6 comments
Labels
js JavaScript

Comments

@haizhilin2013
Copy link
Collaborator

第85天 js延迟加载的方式有哪些?

@haizhilin2013 haizhilin2013 added the js JavaScript label Jul 9, 2019
@fuhao97
Copy link

fuhao97 commented Jul 10, 2019

defer 属性
async 属性
动态创建DOM方式
使用jQuery的getScript方法
使用setTimeout延迟方法
让JS最后加载

@nowherebutup
Copy link

nowherebutup commented Jul 10, 2019

利用setTimeout();

<script id="spt" src="" type="text/javascript"></script>
<script type="text/javascript">
   setTimeout(() => {
     document.getElementById('spt').src = "a.js";
   },1000);
</script>

@dondonZh
Copy link

defer属性 只知道
查阅后知道
setTimeout
动态创建Dom
使用jquery的 getScript

@jim888666
Copy link

defer属性只能在 Internet Explorer 中运行

@MrZ2019
Copy link

MrZ2019 commented Feb 25, 2021

让JS最后加载

@xiaoqiangz
Copy link

defer属性,或者setTimeout动态加载script。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js JavaScript
Projects
None yet
Development

No branches or pull requests

7 participants