项目作者: tylerwolff

项目描述 :
A simple react component for rendering webp images with a fallback for older browsers
高级语言: JavaScript
项目地址: git://github.com/tylerwolff/react-webp-image.git
创建时间: 2018-11-25T23:11:40Z
项目社区:https://github.com/tylerwolff/react-webp-image

开源协议:MIT License

下载


React webp image

npm package

Travis
Coveralls

A simple react component for rendering webp images with an image fallback for older browsers. It uses the <picture> tag to support older browsers without the need for feature detection or a polyfill.

Installation

  1. npm install react-webp-image

or

  1. yarn add react-webp-image

Usage

  1. import Img from "react-webp-image";
  2. import imgPath from "assets/photo.png";
  3. import webpPath from "assets/photo.webp";
  4. <Img src={imgPath} webp={webpPath} alt="I'm a webp image" />;

Any additional props will be passed down to the img tag.

Why use webp?

WebP is a modern image format that provides superior lossless and lossy compression for images on the web. WebP lossless images are 26% smaller in size compared to PNGs. WebP lossy images are 25-34% smaller than comparable JPEG images at equivalent SSIM quality index.

Learn more about webp