Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including swig-minifier with all npm packages installed. Try it out:

var swigMinifier = require("swig-minifier")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

swig-minifier v0.4.2

Automaticly cache and minify html output rendered by swig

What it does

Minifies and caches html output generated by swig (coded to work with express framework, but could be used without)
You have the option to choose file cache, memory cache or redis.
File cache will be located in os.tmpdir() in a folder named 'swig-minifier'


Getting Started

1. Start by installing the package:
npm install swig-minifier
2. Do awesome stuff
var swigMinifier = require('swig-minifier');

// Change your app.engine to set to render with swig-minifier
app.engine('html', swigMinifier.engine);

Your html code will now be automatically minified and cached via file, If you want more options over the module checkout the API below!



    cacheFolder:    String  // Full path to a folder where to store cache (optional)
    cacheType:      String  // file, redis, memory, none
    hashGen:        String  // md5, sha512, sha256

Call this before using the .engine function and you can setup some options for swig-minifier. If you do not call init, default settings will be used:

cacheFolder:    os.tmpdir() + "/swig-minfier/"
cacheType:      "file"
hashGen:        "sha256"

Example for setting to cache to redis and generate the hash for the cache key via sha512

var swigMinifier = require('swig-minifier');


Example for setting to cache to file system, and generate the hash for the cache key via md5

var swigMinifier = require('swig-minifier');



Use this to replace your app.engine setting


var express = require('express');
var app = require('express')();
var swigMinifier = require('swig-minifier');

app.engine('html', swigMinifier.engine);


Will clear all cache

WARNING REDIS USERS: this issues a flushAll command!


var swigMinifier = require('swig-minifier');



You can contact me at


RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free