Code Monkey home page Code Monkey logo

webp-hero's Introduction

webp-hero

webp-hero — live demo

browser polyfill for the webp image format

  • npm install webp-hero

simply add webp-hero.polyfill.bundle.js to your html page, and your webp images come alive in firefox, safari, edge, internet explorer, and of course, chrome

webp-hero actually runs google's libwebp decoder in the browser — it converts webp images to png's on-the-fly

the polyfill renders the decoded image data to a hidden canvas, and converts that to a png data url which is then displayed to the user

webp-hero's polyfill bundle is actually kinda heavy weight at almost 150 KB gzipped

it's a trade-off — it pushes the burden off your bandwidth expense, and onto your user's processor (running the decoder instead of serving up fat images)

features

  • webp-hero.polyfill.bundle.js

    • just run that script on your html page
    • it will decode your page's webp images (currently only img tags)
    • the functionality is directly available with the "webp-hero" common-js module webp-hero.js
  • dwebp.js

    • this is compiled from google's libwebp emscripten build, and then wrapped in a common-js module
    • contains minimal functionality for rendering webp data to a canvas — no polyfilling logic
    • available as common-js module via "webp-hero/dist/dwebp"
    • see the typescript declaration file, dwebp.d.ts, which describes its usage signature

development

  • prerequisites

    • git
    • node
    • docker (if you want to rebuild libwebpjs)
  • development

    • npm install — install dependencies and run build
    • npm start — start http server
    • visit http://localhost:8080/ to see google's web demo
  • build libwebpjs

    • only necessary if you need to change the emscripten build
    • libwebpjs build artifacts are checked in, since it takes so long to build
    • ./libwebpjs-build.sh — use admin privileges (docker requires this)
    • it runs the docker build of libwebp (takes a long time)
    • it writes build artifacts to dist/
    • ./libwebpjs-debug.sh — useful to drop into the container to have a look around

webp-hero's People

Contributors

chase-moskal avatar agamemnus avatar niutech avatar

Watchers

James Cloos avatar  avatar

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.