Skip to content

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

License

Notifications You must be signed in to change notification settings

subtleclass/collapsify

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

246 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

import {simpleCollapsify} from 'collapsify';

await simpleCollapsify('https://example.com', { headers: { 'accept-language': 'en-US' } }) .then(page => console.log(page)) .catch(err => console.error(err));

Collapsify

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

Installation

npm install -g collapsify

Usage

You can use the collapsify CLI like this to download and save the page into a single file like this:

collapsify -o single-page.html https://my-site.com/

see collapsify -h for all options.

API

import {simpleCollapsify} from 'collapsify';

await simpleCollapsify('https://example.com', {
  headers: {
    'accept-language': 'en-US'
  }
})
  .then(page => console.log(page))
  .catch(err => console.error(err));

The simpleCollapsify function takes the URL to collapse, as well as an object of options, and returns a promise that resolves to a String.

Options

  • 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.

Requirements

The simple mode and CLI require nodejs >= 18, as they use the global fetch function.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • JavaScript 59.0%
  • TypeScript 41.0%