Coder Social home page Coder Social logo

polyfill-middleware's Introduction

polyfill-middleware Build Status

http and express middleware serves selective polyfills for javascript based on the requesting user-agent.

which polyfills?

See the polyfill project for details about which polyfills and browsers are supported.

install

npm install polyfill-middleware

use with express

You can use the polyfill middleware with express by specifying which path to serve the dynamically generated js from.

The below examples assumes the following script tag <script src="/assets/polyfill.js"></script>

var polyfill = require('polyfill-middleware');

app.use('/assets/polyfill.js', polyfill());

// alternatively you can limit to just `get` requests
app.get('/assets/polyfill.js', polyfill());

use with node.js http server

The middleware function takes 3 arguments (request, response, done). done should be a function and will be called if the polyfill middleware encountered an error. If there was no error, polyfill middleware will respond to the request.

var middleware = polyfill();

http.createServer(function(req, res) {
    // .. some logic to determine if the request should be handled by polyfill
    middleware(req, res, function(err) {
    });
});

examples

More examples are available in the examples directory.

polyfill-middleware's People

Contributors

defunctzombie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

freeqaz

polyfill-middleware's Issues

caching

Cache files in memory.

Not sure at what layer to cache yet. Possibly at the final bundle (we can actually precompute those on startup). Or just each file.

compress

need an option to compress the final js output

separate lib from middleware

would be cool if the polyfill-creating portion was separated into its own lib, then have the middleware be a separate lib again. just because.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.