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

async和defer的使用区别 #115

Open
xszi opened this issue Mar 27, 2024 · 0 comments
Open

async和defer的使用区别 #115

xszi opened this issue Mar 27, 2024 · 0 comments

Comments

@xszi
Copy link
Owner

xszi commented Mar 27, 2024

async的执行是加载完成就会去执行,而不像defer那样要等待所有的脚本加载完后按照顺序执行,所以两者之间的选择则是看脚本之间是否有依赖关系,有依赖的话应当要保证执行顺序,应当使用defer,没有依赖的话使用async,同时使用的话defer失效。

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

No branches or pull requests

1 participant