简体   繁体   English

HTML ::如何提高在网页上加载图像的性能

[英]HTML :: How to improve performance of loading images on the web page

I have a web page which loads almost 70-80 images on the web page. 我有一个网页,在网页上加载了近70-80张图像。 I already have implemented lazy loading. 我已经实现了延迟加载。 Should I keep these images on local server or on some image site like picasa and reference it from there ? 我应该将这些图像保存在本地服务器上还是像picasa这样的图像网站上并从那里引用它? or is there any better option ? 还是有更好的选择吗? What would be the best way to load these many images without loosing performance and efficiency ? 在不降低性能和效率的情况下加载这些图像的最佳方法是什么?

Please suggest. 请建议。

One more question - is it good idea to add css animation effect to those images ? 还有一个问题 - 为这些图像添加css动画效果是个好主意吗?

There are a number of things you can do. 你可以做很多事情。

  1. Use a tool like smushit - www.smushit.com to optimise images and reduce loading times. 使用像smushit这样的工具 - www.smushit.com来优化图像并减少加载时间。
  2. Make sure that you are not resizing large images by setting incorrect widths and heights. 通过设置不正确的宽度和高度,确保没有调整大图像的大小。
  3. Call images from a subdomain on your server. 从服务器上的子域调用图像。
  4. Combine images used as backgrounds/display elements into a single image (known as a sprite), and use css to only call specific areas of the single image - this means it will only be loaded once, reducing HTTP requests. 将用作背景/显示元素的图像组合成单个图像(称为精灵),并使用css仅调用单个图像的特定区域 - 这意味着它只会加载一次,从而减少HTTP请求。

You can get some advice on using Sprites here: http://css-tricks.com/css-sprites/ 您可以在此处获得有关使用Sprite的一些建议: http//css-tricks.com/css-sprites/

You can also get some more info on page loading times, and things you can do to optimise by using GTMetrix tools at http://gtmetrix.com/ 您还可以获取有关页面加载时间的更多信息,以及可以通过http://gtmetrix.com/上的 GTMetrix工具进行优化的信息。

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

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