defconcepts / collapsify

Collapsify inlines all the resources of a page into a single document

Home Page:https://github.com/cloudflare/collapsify

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Collapsify Build Status

Inlines all of the JavaScripts, stylesheets, images, fonts etc. of an HTML page.

Installation

npm install -g collapsify

Usage

An HTTP server is installed as collapsify-server, which collapses the URL passed to “/?url=”. This HTTP server is systemd-aware: when running as a systemd service, collapsify will listen on the socket passed. Otherwise, this server defaults to listening on port 8020, which can be changed via the “-p” flag.

Additional options can by found via the built in usage information, collapsify-server -h.

API

var collapsify = require('collapsify');

collapsify('http://www.cloudflare.com', {
  headers: {
    Accept-Language: 'en-US'
  },
  logger: console,
}).then(function(output) {
  console.log(output);
});

The “collapsify” function takes the URL to collapse, as well as an object of options, and returns a promise that resolves to a Buffer.

Options

Of these, “logger” is required.

  • logger: An object that exposes a bunyan instance-like API.
  • headers: An object of headers, to be added to each HTTP request.
  • forbidden: A regex that matches blacklisted resources that should be avoided while navigating.

About

Collapsify inlines all the resources of a page into a single document

https://github.com/cloudflare/collapsify


Languages

Language:JavaScript 94.9%Language:Makefile 5.1%