简体   繁体   English

更改具有宽度和高度的图像的 src 会导致 DOM 抖动吗?

[英]Does changing the src of an image with a width and height cause DOM thrashing?

如果我有一个宽度/高度设置为<img width=x height=x src=blank_pixel />的图像标签,并且我将 src 更改为某个图像 url,这会导致 dom 布局无效吗?

Using chrome dev tools I see next sequence:使用 chrome 开发工具,我看到了下一个序列:

  1. Recalculate style + Layout + Update layer tree重新计算样式 + 布局 + 更新图层树
  2. Paint
  3. Composite Layers复合层

My answer is yes.我的回答是肯定的。 Browser donwload new image, scale it (if it's necessary) and then calculate layout, do the paint and composite the image.浏览器下载新图像,缩放它(如果有必要),然后计算布局,绘制并合成图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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