npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

urify-emitter

v1.1.2

Published

emits files instead of inlining base64 urls

Downloads

9

Readme

urify-emitter

experimental

Similar to webpack's file-loader, this builds on the urify transform but emits a file into an application-level output directory. This allows for modular front-end code which relies on images and icons, without increasing JS bundle size or sacrificing browser image caching optimizations.

Example front-end code:

var datauri = require('datauri')
var uri = datauri(__dirname+'/icon.png')

var img = new Image()
img.onload = function() {
	console.log("Image loaded!")
}
img.src = uri

Now, from your application, you can bundle the code using the urify-emitter plugin.

browserify -p [ urify-emitter -o images ] index.js > bundle.js

This will emit a bundle.js file, which inlines the URI like so:

var uri = 'images/53cf2c1426533b467d606312b4e246ef.png'

It will also copy the static asset icon.png with the above hashed URL to your specified output directory, in this case images.

You can also specifiy a --limit (or -l) option, and if the file is under that size in bytes, it will be inlined as a regular data URI.

bundle-wide

The plugin only transforms source at the top-level (i.e. application). To transform all module code throughout a bundle, you will need browserify v.6.1.0+ and the --ignore-transform command to override all urify transforms:

browserify -p urify-emitter --it urify index.js > bundle.js

gulp, grunt, npm scripts

For a practical implementation of this, see urify-example.

Usage

NPM

  • --output, -o the output directory, defaults to .
  • --limit, -l the limit in bytes, under which we will inline with a Data URI
  • --base, -b an optional base to use on the inlined URL, which is joined with the asset name. For example, your local output directory might be in app/output, but your site URLs you can specify --base output so they look like output/53cf2c14265..png

License

MIT, see LICENSE.md for details.