Javascript Performance: Multiple script blocks Vs single bigger block

走远了吗. 提交于 2019-12-04 09:38:37

When a browser encounters a script block it has to pause rendering the page while it executes the script in that block.

I'm not sure why this would be so pronouced for IE8 over FF. It could be that the context switch is especially costly in IE8, or that FF may do some work behind the scenes to combine your blocks if it determines it can (I'm only guessing here)

Script blocks also block parallel downloads. If you're downloading images from multiple hostnames, this can happen in parallel, unless you are executing a script block.

In general, I would say that it is best practice to combine your script blocks. Personally, I would recommend you move them into a separate file.

Incidentally, what happens with your metrics when you do move it to another file?

See Best Practices for Speeding Up Your Web Site at Yahoo Developer.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!