css-inline

A WASM package for inlining CSS into HTML documents

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
css-inline
0.8.120 days ago8 years agoMinified + gzip package size for css-inline in KB

Readme

css-inline
ci npm version
Blazing-fast WASM package for inlining CSS into HTML documents.
Features:
  • Removing `style` tags after inlining;
  • Control if `style` tags should be processed;
  • Out-of-document CSS to inline;

The project supports CSS Syntax Level 3 implemented with Mozilla's Servo project components.

Usage

import { inline } from "css-inline";

var inlined = inline(
  `
  <html>
    <head>
      <title>Test</title>
      <style>h1 { color:red; }</style>
    </head>
    <body>
      <h1>Test</h1>
    </body>
  </html>
  `,
  { remove_style_tags: true }
)
// Inlined HTML looks like this:
// <html>
//   <head>
//     <title>Test</title>
//   </head>
//   <body>
//     <h1 style="color:red;">Test</h1>
//   </body>
// </html>
// Do something with the inlined HTML, e.g. send an email