The New Competitive Image Format For Web ๐Ÿ‘‰ WebP

WEBP is a new image compression technology that creates smaller file sizes without compromising on quality

ยท

2 min read

The New Competitive Image Format For Web ๐Ÿ‘‰ WebP

WebP can reduce the file size from 20% to 80% (or even more) compared to JPEG, PNG, and GIF

xwebp-vs-png-lossless-compression-1120x642.pagespeed_.ic__.ayj7ulmvj-1066x611_1.png

Key Features


๐Ÿ”ท Developer by Google in 2010

๐Ÿ”ท Open Source

๐Ÿ”ท Extension -> .webp

๐Ÿ”ท MIME type -> image/webp

๐Ÿ”ท Lossless Compression

๐Ÿ”ท Supports Animation

๐Ÿ”ท Supports Alpha Transparency

๐Ÿ”ท Used by Google, Bind, Facebook

Browser Support


โœ… Chrome >= v9 (2011 year)

โœ… Firefox >= v65 (2019 year)

โœ… Opera >= v11.5 (2011 year)

โœ… Edge >= v19 (2019 year)

โœ… Safari iOS >= v14.4 (2020 year)

โœ… Safari* >= v14 (2020 year) // Safari needs macOS 11 or later

โ›” Internet Explorer* (no native support) // IE needs fallback/polyfill

Screenshot_14.jpg

How To Use


1) Using <picture> + <img> tag

<picture>
  <source srcset="img/original.webp" type="image/webp">
  <source srcset="img/fallback.jpg" type="image/jpeg"> 
  <img src="img/fallback.jpg" alt="Alt Text!">
</picture>

Note This option is recommended, the browser will select its own supported format

2) Using <img> tag only

  <img src="img/fallback.jpg" alt="Alt Text!">

Note Only choose this option if you don't care about old browsers (like Internet Explorer)

How To Create


Google has created its own package for Linux, Windows and macOS with command-line tools that can be used to transform your existing images (PNG, GIF, JPG) to WEBP format

Link: developers.google.com/speed/webp/download

This package includes:

  • The libwebp library, which can be used to add WebP encoding or decoding to your programs.
  • cwebp -- WebP encoder tool
  • dwebp -- WebP decoder tool
  • vwebp -- WebP file viewer
  • webpmux -- WebP muxing tool
  • gif2webp -- Tool for converting GIF images to WebP

Usage (Windows Example)

cwebp.exe delivery_parcel.png -q 80 -o delivery_parcel.webp
  • delivery_parcel.png - source file
  • -q 80 - quality param set to 80%
  • -o delivery_parcel.webp - output file

Online Converters

CMS & JS Frameworks Support


CMS

JS Frameworks (that has optimized image component)

  • NextJS
  • Gatsby
  • Nuxt

CDN Automatic Conversion


Some CDNs support automatic next-gen conversion of your images, like Cloudflare (although it's not a free feature and comes with a PRO plan - $20/mo)

Thanks for reading ๐Ÿ‘

Follow me on Twitter - twitter.com/therceman

ย