图像精灵的高度重要吗?

发布于 2024-10-15 00:14:52 字数 113 浏览 2 评论 0原文

您认为拥有一个图像精灵有什么问题吗? 30px × 27,900px 的

图像几乎 90% 是空白。它只有 9.5kb,但在浏览器中运行这么大的东西似乎有些不对劲。

想法或想法?

Is there any problem you can think of having an image sprite that is
30px × 27,900px

the image is almost 90% white space. its only 9.5kb but something just doesn't seem right about having something this big running in a browser.

Thoughts or ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天煞孤星 2024-10-22 00:14:52

仅仅因为它在磁盘上的大小为 9.5Kb,并不意味着它不会在浏览器中占用大量内存,浏览器必须先解压缩图像才能显示。 (最终大小取决于所使用的压缩等)

因此,虽然它显然会花费额外的连接,但我建议如果可能的话将其分解为更小的图像。

Just because it's 9.5Kb on disk, doesn't mean that it won't occupy a large amount of memory in the browser, which has to decompress the image before it can be displayed. (The final size depends on the compression used, etc.)

As such, whilst it'll obviously cost an extra connection I'd recommend breaking this down into smaller images if at all possible.

颜漓半夏 2024-10-22 00:14:52

FWIW,当存在大量偏移时(例如通过将其放置在左侧 10000px 来隐藏 DIV),浏览器性能似乎不会降低。

图像处理通常使用二维数组完成,因此可以非常轻松地访问图像的任何部分,而不需要线性遍历。因此,如果您指示 16x16 像素图标位于 5000、3000,渲染引擎可以很容易地找到这些像素。

当然,两个明显的问题是:

  1. 为什么需要这么多空白?
  2. 你测试过性能吗?

FWIW, Browser performance doesn't seem to degrade when there are massive offsets (such as hiding a DIV by putting it 10000px to the left).

Image processing is often done with two dimensional arrays, and thus access to any part of the image can be done quite easily and without requiring linear traversal. So if you indicate that an 16x16 pixel icon is located at 5000, 3000 the rendering engine can locate those pixels quite easily.

Of course, the two obvious questions are:

  1. Why do you need so much whitespace?
  2. Have you tested for performance?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文