PageSpeed accuses script of “render-blocking” when using external image

China☆狼群 提交于 2019-12-05 21:40:58

I thought scripts before the end of my </body> don't delay the rendering?

Correct, they don't.

For instance, for me, this (with the image) triggers the render-blocking warning for https://code.jquery.com/jquery-3.1.1.min.js:

...

If I remove the img, the render-blocking-JavaScript warning disappears.

I'd report that as a bug. I don't see anything render-blocking about that script. I even tried wrapping the img in a fixed-size, overflow: none div, and still got the error. Can't see why that script would be render-blocking; if you report it as a bug, and it turns out there's a reason, well, that's a good result. But more likely it's a bug.

IMHO your believe is correct, Google's PageSpeed should be referring to the resources blocking some page rendering time b/c its executing the scripts synchronously so in theory your page is still loading, defer will execute them async and that's why it doesn't complaint after you change them to be loaded in defer mode. You can check this nice post that explains it really well here.

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