zoukankan      html  css  js  c++  java
  • [HTML 5 Performance] Optimize Cross-browser Images with webp and the 'picture' Element

    "Legacy" image formats like jpg and png are often 2-3x larger than "next-gen" image formats like webp. In this video, we'll see how to convert our images using the cwebp utility, as well as how to use the <picture> HTML element to set fallbacks, for browsers that don't support the webp format.

    Installation instructions:

    • For MacOS, you can use homebrew: brew install webp
    • For Windows and Linux, you'll need to download the appropriate precompiled utility from their downloads page

    Run:

    cwebp -q 70 cat.jpg -o cat.webp

    HTML: with jpg fallback

        <picture>
          <source srcset="cat.webp" type="image/webp" />
          <img src="cat.jpg" class="cat-photo" alt="A cat hunting a toy bird" />
        </picture>
        <picture>
          <source srcset="me.webp" type="image/webp" />
          <img src="me.png" class="me" alt="3D Josh" />
        </picture>
  • 相关阅读:
    第五次博客作业
    第三次博客作业
    个人简介
    实验三
    实验二
    实验一
    《构建之法》心得体会
    第三次博客园作业
    软件测试实验二
    个人简历
  • 原文地址:https://www.cnblogs.com/Answer1215/p/12576672.html
Copyright © 2011-2022 走看看