Node utility to inline images, CSS and JavaScript for a web page - useful for mobile sites
Go to file
Joey Parrish 68c345ae8e feat: inline favicons with rel="shortcut icon"
If the page is using rel="shortcut icon" instead of rel="icon", the
author will be surprised that the icon was not inlined, and may not
notice.  It would be better to inline that icon.

Includes updates to the favicon tests.

Related to issue #126
2016-11-17 11:19:59 -08:00
cli fix: better reporting of progress 2016-07-31 12:59:08 +01:00
docs docs: fix help -H sample 2016-06-27 18:12:42 +01:00
lib feat: inline favicons with rel="shortcut icon" 2016-11-17 11:19:59 -08:00
test feat: inline favicons with rel="shortcut icon" 2016-11-17 11:19:59 -08:00
.editorconfig chore: added editorconfig 2015-11-26 10:29:27 +00:00
.gitignore chore: ignore tmp folders 2016-04-19 11:19:40 +01:00
.jscsrc test: put jscs as part of tests 2015-07-28 13:40:09 +01:00
.jshintrc refactor: HTML pulling down, events, images 2015-07-26 16:44:49 +01:00
.npmignore chore: skip test dir in npm pkg 2016-04-20 09:46:36 +01:00
.travis.yml fix: better reporting of progress 2016-07-31 12:59:08 +01:00
CODE_OF_CONDUCT.md docs: add code of conduct 2015-09-12 18:02:15 +01:00
CONTRIBUTING.md test: improve coverage 2016-02-28 09:51:10 +00:00
MIT-LICENSE.TXT + license 2011-06-22 18:21:24 +01:00
package.json fix: update deps (out of vuln range) 2016-07-31 15:38:46 +01:00
README.md docs: Suggest service worker instead of appcache (#115) 2016-08-13 18:11:49 +01:00

Inliner

Turns your web page to a single HTML file with everything inlined - perfect for appcache manifests on mobile devices that you want to reduce those http requests.

Build Status

What it does

  • Get a list of all the assets required to drive the page: CSS, JavaScript, images, videos and images used in CSS
  • Minify JavaScript (via uglify-js)
  • Strips white from CSS
  • Base64 encode images and videos
  • Puts everything back together as a single HTML file with a simplfied doctype

Installation

Install the inliner utility via npm:

$ npm install -g inliner

Usage

If you have either installed via npm or put the inliner bin directory in your path, then you can use inliner via the command line as per:

inliner http://remysharp.com

This will output the inlined markup with default options. You can see more options on how to disable compression or how not to base64 encode images using the help:

inliner --help

To use inline inside your own script:

var Inliner = require('inliner');

new Inliner('http://remysharp.com', function (error, html) {
  // compressed and inlined HTML page
  console.log(html);
});

Or:

var inliner = new Inliner('http://remysharp.com');

inliner.on('progress', function (event) {
  console.error(event);
}).on('end', function (html) {
  // compressed and inlined HTML page
  console.log(html);
});

Once you've inlined the crap out of the page, you can optionally configure a service worker to add advanced caching and offline functionality.

Support

  • Collapses all white space in HTML (except inside <pre> elements)
  • Strips all HTML comments
  • Pulls JavaScript and CSS inline to HTML
  • Compresses JavaScript via uglify (if not compressed already)
  • Converts all images and videos to based64 data urls, inline images, video poster images and CSS images
  • Imports all @import rules from CSS (recusively)
  • Applies media query rules (for print, tv, etc media types)
  • Leaves conditional comments in place
  • If JavaScript can't be imported (or is Google Analytics), source is not put inline

Limitations / Caveats

  • Whitespace compression might get a little heavy handed - all whitespace is collapsed from n spaces to 1 space.

Filing issues & PRs

Please see the contributing for guidelines.