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

html-inline

v1.2.0

Published

inline javascript, stylehseets, and images from an html page

Downloads

8,672

Readme

html-inline

inline javascript, stylesheets, and images from an html page

build status

example

input file:

<html>
  <head>
    <link rel="stylesheet" href="/yo.css">
  </head>
  <body>
    <img src="icon.png">
    <script src="hey.js"></script>
  </body>
</html>

output:

$ html-inline index.html
<html>
  <head>
    <style>body {
  background-color: cyan;
}
</style>
  </head>
  <body>
    <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAFcwAABXMBNzKusgAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAhPSURBVHic3Zt/cFRXFcc/5y1JIP6oRG1lWmutJU0WtLRaZEaH2l+O/2A7U9JWHQWqBWuLimInQHYvd7MJYAewLVhg2lK106JpZ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ypoeZWb18wClbsd3AzNGcDnjFqziiv9VL+m4AFCRIzyx3Q+AZCXmnZrtIpM8KJWOweYHYUzWPAQILEjKDTJyv2Kr864tClsgDt0v7JAoXdhE+cxIENRk3oaDVS2qpAoQ934ZkwCHI4En+EYunzgRcILkoaD/QD1xg1e8Iwh5oB22RbDe6p7UQbD24t4FOd0nlBGOaw9wW2AkEXGI7hnscVvEfwKjarELMX+FPRGEngUwH0zwPX+y7aPqj6zpBXRL0wiEaQVWlNP1LCdxmwAffQNQjHBFmRJv0YOhJ0WbFNBN8qmwNch3tR422j6lfA+5zMAH7pQ9JTT/2OMnyHvEAk6Lz+F0BjWtPbi433+A/gVnqV5UuQSBo1VRkPIW+NGTWHgJus2Btwz+tmFnU/sVyX9/rxCjKg/tH04eIStjLYzug8xT7c8HanD31FRPoMGjU7kyRnAXfjHqbg4GwL4vEOJvwwvYLIHcBbwHFB7kmSnBXFeIjhaKxFW/JGzQ9x01fLUpp6qQJLMqAvMAVm1PQIsqiOuulpTW+O455xpEgwDKzYV4FLfLoHkiSnnLO3x73NiQKv+dHkyE3DvQk2Lvg/7y7guqiIKXAAAAAASUVORK5CYII=">
    <script>console.log('oh hey');
</script>
  </body>
</html>

usage

html-inline {-i INFILE -o OUTFILE -b BASEDIR}

  Read an html file from INFILE to produce OUTFILE, inlining stylesheets, script
  tags, and images relative to BASEDIR.

  -i File to read. Default: STDIN.
  -o File to write. Default: STDOUT.
  -b Directory to resolve paths from. Default: $PWD.

  --ignore-images  Don't inline images. Default: false
  --ignore-scripts Don't inline JavaScript. Default: false
  --ignore-styles  Don't inline CSS. Default: false
  --ignore-links   Don't inline <link> tags. Default: false

methods

var inliner = require('html-inline')

var inline = inliner(opts={})

Create a transform stream inline that expects html as input and produces html with inline assets as output.

Paths to scripts, stylesheets, and images are resolved relative to opts.basedir.

You can disable asset inlining by passing true for:

  • opts.ignoreImages
  • opts.ignoreScripts
  • opts.ignoreStyles
  • opts.ignoreLinks

install

With npm, to get the command do:

npm install -g html-inline

and to get the library do:

npm install html-inline

license

MIT