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

dataurify-html

v1.0.0

Published

Simple cli utility to convert single HTML files to data URIs

Downloads

6

Readme

node-dataurify-html

Simple cli utility to convert single HTML files to data URIs

Simple example

To get a data URI version of the original data URL specification:

npm install -g dataurify-html
curl -s 'https://tools.ietf.org/html/rfc2397' | dataurify-html

Example with inlined assets

Remy Sharp has made a wonderful tool called inliner which can be very helpful when bundling your application as a data URI:

npm install -g dataurify-html inliner
inliner 'https://remysharp.com' | dataurify-html

How to test long data urls

It is really difficult (and sometimes impossible) to copy & paste long data URIs to the address bar. It is also impossible to pass arguments larger than getconf ARG_MAX to a console command, which on OSX means no arguments larger than 262144 characters.

On OSX, if your data URI is shorted than about 255 kB, you can get past the open command not detecting data URIs as URLs by passing the URI through osascript:

osascript -e 'tell application "Google Chrome" to open location "'`curl -s 'https://github.com' | dataurify-html`'"'

If you have a longer data URI, I believe your best option is to create a web page which contains the data URI, and open that. At the time of writing both Chrome and Edge have disabled top level navigation to data URIs due to phishing security concerns, and other browsers might follow later, so that means location.href = dataURI and <a href="dataURI"> might not work for you.

Iframes with a data URI source still work in all browsers, and are expected to stay like that for a while, so that is one good option:

export FSTART='<iframe style="width:100%;height:90%" src="'
export FEND='" />'
inliner 'https://remysharp.com' | dataurify-html | perl -pe 'chomp; $_ = $ENV{FSTART}. $_ .$ENV{FEND}' > framed.html; open framed.html