且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

动态创建脚本标记和静态嵌入脚本标记有什么区别?

更新时间:2023-12-05 21:41:10

他们这样做是为了让它以异步方式加载,或者在至少所以只有在正常的JS加载并执行后才会加载它。它避免了渲染树等待加载这个JS,因此页面更快。

They do it so that it loads asynchronously, or at least so it is only loaded once the normal JS has loaded and been executed. It avoids making the rendering tree wait for this JS to load so the page is quicker.