开发者

Load images dynamically without blocking UI in Javascript on mobile application?

So I'm attempting to load images in javascript dynamically as the user is scrolling around. The entire application is offline and 开发者_如何学Gois written in HTML and javascript. The "scrolling" around behavior is done through CSS3 animations.

The problem is that when I set image.src = "foo.png" it blocks the UI until the image has loaded. Is there a way around this?


How long is the UI being blocked? If it is local then I wouldn't have thought it much at all.

Anyhow, the reason the UI may be being blocked is because it needs to download the image to determine its size. If it doesn't know the image size it will not know how it will affect the layout.

The first think I would do is to set with and height attributes as soon as the tag is created.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜