1.0.4 • Published 8 years ago

webp-jxr-middleware v1.0.4

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

CircleCI API Doc Coverage Status Dependencies DevDependencies

Installation

npm install webp-jxr-middleware

Usage

webp-jxr-middleware should be used before any middleware that is serving files (e.g. express.static) so that it serves changed format file.

import rewriteImg from 'webp-jxr-middleware';
import express from 'express';
import { join } from 'path';

const app = express();
const serverPath = join(__dirname, 'public');

app.use(rewriteImg(serverPath));
app.use(express.static(serverPath));

ES5

An ES5 compatibility build is also included at lib/es5.js. To generate it from the source, run npm run build.

You can then require it like:

var rewriteImg = require('webp-jxr-middleware/lib/es5').default;

Overview

Middleware to serve JXR and WEBP images when the browser supports them. Works with Connect and Express.

It is based off connect-image-optimus and accept-webp. It maintains support for webp and jxr from the connect-image-optimus and avoids the UA parsing like accept-webp.

Development Setup

  1. Fork the repo
  2. Run npm install
  3. Run ./node_modules/.bin/precommit install
  4. Run npm run dev to initiate the development server

Contributing

  1. Commit your changes following conventional-changelog format
  2. Push to a new branch (e.g. git push origin my-awesome-feature)
  3. Create a new Pull Request

License

MIT

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago