Home  >  Q&A  >  body text

php - 网站轮播图如何加载速度快

进入首页 首页的轮播图6张 是从数据库里面读取地址加载出来的 打开时候需要加载很久 请问有什么方法吗 排除懒加载 图片已经进行过压缩

给我你的怀抱给我你的怀抱2737 days ago634

reply all(4)I'll reply

  • 巴扎黑

    巴扎黑2017-05-16 13:01:36

    You can use preloading, it will be loaded when you just visit

    reply
    0
  • 黄舟

    黄舟2017-05-16 13:01:36

    1. If possible, use webp or tinyPNG for pictures;

    2. Size to match the actual size of the carousel component, or create another thumbnail;

    3. CDN;

    4. http/1.x upgraded to http/2;

    5. Cache to localStorage, the format is base64, set an expiration reload mechanism;
      ...

    I’ll add more when I think of it

    reply
    0
  • 阿神

    阿神2017-05-16 13:01:36

    Simple, fast and threshold-free method:

    1. Configure gzip compression on the server yourself

    2. Spend some money to get a small file storage + CDN to serve together, such as Qiniu, OSS, Youpai...

    More complicated, a bit threshold, and it depends on whether it is suitable for the specific application scenario:

    1. Consider using Zhihu’s similar lazy loading effect, but it is much better than the traditional lazy loading experience, full of style, split the size of the image according to logic (or use the api of the cdn service to change the parameters), the default loading is small image, and then load the large image with the transition effect.

    Please see this link for the effect: https://zhuanlan.zhihu.com/p/...
    Small picture: https://pic2.zhimg.com/v2-bf1...
    Large picture: https:// pic2.zhimg.com/v2-bf1...

    1. Consider new image formats, such as Google's webp. Lossy compression is estimated to be about 30% smaller than jpg, and lossless compression is estimated to be about 60% smaller than jpg. There is also Tencent's latest self-developed format TPG, which I have introduced in the past two days. Flying all over the sky

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 13:01:36

    Follow The Walking Dead The Walking Dead

    reply
    0
  • Cancelreply