背景图片多大算太大?
我这里有一个小问题。我是一名网络开发专业的学生,目前正在为我需要做的一个项目构建这个网站。我想让背景图片看起来很漂亮。我在 Photoshop 中创建了该图像,并将其以 .jpg 格式保存到网络上,最终大小为 58.8k
。
我完全支持用户加载速度快的网站,但我想知道小于 60k 是否可以?我在 yslow firefox 扩展上检查了它,它在 96 毫秒内为我加载(测试主题稍差 - http ://www.speedtest.net/result/1146275377.png)
60k 是否太多了,图像只有 10-20k 是最佳实践吗?当我看到图像加载时,我讨厌它......它只是......甚至不值得此时的图形。有没有更快的方法来加载该尺寸的图像? CSS 还是标签?或者我根本不应该担心它?
I am having a little issue here. I am a web development major and I am currently building this site for a project I am required to do. I wanted to make it look pretty with a background image. I created the image in Photoshop and saved it to web as a .jpg and it ended up being 58.8k
in size.
I am all for websites that load quick for the user, but I am wondering if less than 60k is okay? I checked it on the yslow firefox extension and it loads for me in 96 ms (slightly poor test subject - http://www.speedtest.net/result/1146275377.png)
Is 60k too much, is it a best practice to have images only 10-20k? I HATE it when I see an image loading... it just.. isn't even worth the graphic at that point. Is there quicker ways to load a image of that size? CSS or tag? Or should I not even be worrying about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
大多数浏览器默认最后加载背景图像,因此您应该不会有问题。
多大才算太大取决于您的托管设置、网站获得的流量以及访问者的典型传输率。
对于一个没有太多同时访问者的普通网站来说,60k 对我来说似乎是合理的。然而,带宽需要花钱,这就是您很少在大型网站上看到这种大小的背景图像的原因。另一方面,YouTube 定期传输比您建议的背景图像大数千倍的视频。如果不了解有关您的网站、其托管解决方案及其使用统计数据的更多信息,就不可能为您提供准确的建议。
如果您问这个问题,很可能 60k 就完全没问题了。
如果您想保证背景图像首先或最后加载,您可以执行以下操作:
将该代码放置在正文标记上方以预加载背景图像。将其放在 html 文档的较低位置以便稍后加载(例如,在
标记之后最后加载背景)。
然后在 body 标签中:
Most browsers load the background image last by default, so you shouldn't have a problem.
How large is too large depends on your hosting set up, the amount of traffic your site gets, and the typical transfer rate of your visitors.
60k seems reasonable to me for an average site with not too many simultaneous visitors. However, bandwidth costs money and this is the reason that you rarely see background images of that size on big sites. On the other hand, youtube regularly streams videos that are thousands of times larger than the background image that you propose. It's impossible to give you precise advice without knowing much more about your site, its hosting solution and it's usage statistics.
Chances are, if you're asking this question, 60k is perfectly fine.
If you want to guarantee that your background image loads first or last you can do:
Place that code above the body tag to preload the background image. Place it lower in your html document to load it later (e.g. after the
</body>
tag to load the background last).And then in the body tag:
我不认为 60k 太大,尽管您可能想查看可能的用户并考虑他们的连接速度。如果您想尝试尽可能缩小文件大小,请尝试smushing好吧,你可能会看到它进一步下降。
I don't think 60k is too large although you probably want to look at your likely users and think about what their connection speeds will be like. If you wanted to try and squeeze the file size down as much as possible, try smushing it as well and you might see it drop a little further.