optimicss
Server side CSS optimizer
Last updated 2 years ago by camilo.tapia .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install optimicss 
SYNC missed versions from official npm registry.

Optimicss

A simple css optimizer that takes in your html and your complete css and returns onyl the CSS content that existed in the HTML. Since that might not be enough, you can also send in a include with wildcards.

How to use it

Simple example:

const optimicss = require('optimicss');

const css = `body { padding: 20rem; } .foo { background-color: red; } .bar { color: lime; } 
.datamaskin { font-family: serif; } .tjena { color: black; } .tjena--hej { color: yellow; }`;

const html = `<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
</head>
<body>
    <div class="foo"></div>
    <div class="bar"></div>
</body>
</html>`;

async function run () {
    let opmizedCss = await optimicss({html, css});
    console.log(opmizedCss);
}

run();

Example with include:

const optimicss = require('optimicss');

const css = `body { padding: 20rem; } .foo { background-color: red; } .bar { color: lime; } 
.datamaskin { font-family: serif; } .tjena { color: black; } .tjena--hej { color: yellow; }`;

const html = `<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
</head>
<body>
    <div class="foo"></div>
    <div class="bar"></div>
</body>
</html>`;

async function run () {
    let opmizedCss = await optimicss({html, css, include: ['.tjena*']});
    console.log(opmizedCss);
}

run();

Options

let opmizedCss = await optimicss({
    html: 'YOUR HTML STRING',   // Your pages HTML
    css: 'YOUR COMPLETE CSS',   // Your complete CSS including everything
    include: ['.foo*'].       // An array of strings with optional wildcards to include no matter what,
    cache: true,                // Use your HTML and the include as a key to cache the result for the next time. 
                                // Defaults to true
});

Current Tags

  • 0.3.10                                ...           latest (2 years ago)

5 Versions

  • 0.3.10                                ...           2 years ago
  • 0.3.9                                ...           2 years ago
  • 0.3.5                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.0.5                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 9
Dependencies (4)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |