图像预加载不适用于FireFox中的图像 [英] Image preloading isn't working for images in FireFox

查看:82
本文介绍了图像预加载不适用于FireFox中的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在动态切换背景图片。当然,它们需要预先加载才能及时显示。我正在预加载它们,能够在FireBug中跟随图像加载。当背景图像切换时,我在FireBug中再次看到图像下载。

I'm dynamically switching background images. Naturally, they need to be preloaded to display promptly. I am preloading them, am able to following in FireBug as the images load. When the background image switches, I see the images download again in FireBug.

这是我的网址: http:// www。 morganpackard.com/siteRoot/

奇怪的是,如果我重新加载页面,一切都按预期工作。我正在采取的步骤如下:

Strangely, if I reload the page, everything works as expected. The steps I'm taking are as follows:

1)清除FireFox缓存
2)重新加载页面
图像加载缓慢,显然是既没有预加载也没有缓存。每次图像交换时,图像都会再次下载。
3)现在重新加载页面而不清除缓存
图像加载并立即交换,一切都按预期工作。

1) clear FireFox cache 2) reload page Images load slowly, and, apparently are neither being preloaded nor cached. Every time there's an image swap, the image downloads again. 3) now reload the page again without clearing the cache Images load and swap instantly, everything works as expected.

所以它看起来像我在FireFox从缓存中读取图像之前必须要RELOAD。这很怪异。有什么想法?

So it looks like I'm having to RELOAD before FireFox will read images from the cache. This is kooky. Any ideas?

注意:我的图片非常好。当然,我会压缩它们,但是想要首先对这个预加载进行排序。

Note: My images are ENORMOUS. I'll compress them, of course, but want to get this preloading this sorted first.

推荐答案

我没看过你的代码,但是为了预加载工作,你必须将图像添加到文档DOM,否则它可以被积极地垃圾收集。

I didn't read your code, but for preloading to work, you must add the image to the document DOM, otherwise it can be garbage collected aggressively.

这篇关于图像预加载不适用于FireFox中的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆