Skip to main content

shoe-horn a web page into a single html file

Project description

Make HTML more self-contained by in-lining:

  • JavaScript (minified)
  • CSS (minified)
  • Images (base-64 encoded)
    • Including (explicitly linked) favicons

For straightforward cases, this will take an HTML document which might have external dependencies and return an HTML document with no external dependencies - a single self-contained file that you could send as an email attachment, or show as a presentation without worrying about internet connectivity, for example.

Cases that are not straightforward are those that involve loading things via JavaScript, iframe things, fonts, and things I haven’t thought of. Pull requests welcome!

Usage

Loaded as a module, selfcontain() takes an HTML string and base path or URL and is the main function to know. Command-line usage wraps the minor extension selfcontain_ref(), which takes a string specifying a file path or URL to fetch and process:

selfcontain test_in.html > test_out.html
# or
selfcontain https://raw.githubusercontent.com/ajschumacher/selfcontain/master/test_in.html > test_out.html

Project details


Release history Release notifications

This version
History Node

0.2

History Node

0.1.1

History Node

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
selfcontain-0.2.tar.gz (3.1 kB) Copy SHA256 hash SHA256 Source None Aug 11, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page