Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between defer and async in js

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces what is the difference between defer and async in js. It is very detailed and has a certain reference value. Friends who are interested must read it!

The difference between defer and async?

Both load external JS files asynchronously and do not block DOM parsing

Async is executed after the external JS is loaded and before the Load event is triggered when the browser is idle. Scripts marked async are not guaranteed to be executed in the order in which they are specified, and this attribute has no effect on inline scripts (that is, scripts without the * * "src" * * attribute).

Defer is executed after JS loading, after the entire document parsing is complete, and before triggering the DOMContentLoaded event. If the src attribute (that is, embedded script) is missing, it should not be used because it does not work in this case.

The above is all the content of the article "what's the difference between defer and async in js". Thank you for reading! Hope to share the content to help you, more related knowledge, 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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report