简体   繁体   中英

Next JS Script Component Vs normal script tag with async and defer

next js <Script />组件渲染策略( afterInteracivebeforeInteractivelazyLoad )和使用带有asyncdefer的普通<script />标签有什么区别?

afterInteractive , beforeInteractive and lazyLoad handles script and decide when it's loaded (from docs ). It also differ in 'place' where it loads the script. beforeInteractive loads your script in <head> of your project. afterInteractive loads your script in <body> of your project.

Basically, it's just Nextjs way to handle scripts in your app. Main difference is that you should not use script tag in head ( in Nextjs ) but place it anywhere else and use right strategy so Nextjs knows where to place it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM