This rule is triggered when PageSpeed Insights detects that a picture on a Web page can be optimized to reduce its size without significantly affecting its visual effect.

Overview

Minimize the picture size to reduce the time users wait for resources to load. Formatting and compressing pictures properly can save a lot of data byte space. This saves time for users with slower network connections and costs for users with limited traffic packages.

Recommendations

You should perform basic and advanced optimizations for all pictures. Basic optimizations include cropping unnecessary areas, reducing color depth to the lowest acceptable level, removing picture comments, and saving pictures in the appropriate format. You can use any picture editing program (for example,GIMP). Advanced optimizations include further compression (lossless compression) of JPEG and PNG files.

Using the Picture Compression Tool

There are many tools available for further lossless compression of JPEG and PNG files without any impact on image quality. For JPEG files, we recommend that you use thejpegtranjpegoptim(Linux only; Use--strip-all选项运行)。对于PNG文件,我们建议使用OptiPNGPNGOUT.

Choose the appropriate picture file format

您应测试一下哪种格式最适合您的图片,尽管我们在下面推荐了一些较高级别的格式:

  • PNG格式几乎一直优于GIF格式,尽管某些旧版浏览器只能为PNG格式提供部分支持
  • Use the GIF format for smaller or simpler graphics (for example, graphics less than 10x10 pixels or graphics with a palette less than 3 colors) and pictures that contain animations.
  • 为所有摄影风格的图片使用JPG格式。
  • 请勿使用BMP格式或TIFF格式。

 

Except as other written, the content of this page is licensed under theCreative Commons Attribution 3.0 License, and code samples are licensed under theApache 2.0 License. For details, see our Site Policies.