npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-minify-tag

v0.0.1

Published

You can use this code to minify your css and js code between begin and end comment tags in a given html file.

Downloads

63

Readme

minify-tag

Minifier of js, css, html.

It is a wrapper for the gorgeous node-minify.

You can use it programmatic as script or as CLI.

Advantage / Motivation: Instead of separate mapping files and html code the needed informations can be set with help of html comments:

<html>
<head>
    <!-- node-minify-tag-glob( {"htmlOut": "_index1.prod.html"} ) -->
    ...
    <title>index1</title>
    ...
    <!-- node-minify-tag( {"fileOut":"_abc1.min.css", "type": "no-compress"} ) -->
    <link href="css/base.css" rel="stylesheet">
    <link href="css/base2.css" rel="stylesheet">
    <!-- node-minify-tag-end -->
</head>
<body>
...
<!-- node-minify-tag( {"fileOut":"_abc.min.js", "type": "no-compress"} ) -->
    <script src="js/jquery-2.0.3.js"></script>
    <script src="js/base.js"></script>
    <script src="js/base2.js"></script>
<!-- node-minify-tag-end -->
...

Usage

As script :

var minifyTag = require('node-minify-tag');

// HTML in and out file are explicitly specified: 
// No need for 'node-minify-tag-glob' tag:
minifyTag.minify({
        relativeBaseDir: "demo",
        htmlIn: "abc.dev.html",
        htmlOut: "__abc.prod.html",
        encoding: "utf8",
        mergeNgIncludes: true
    }, 
    function (err, msg){
        if (err) return reject(err);
        resolve(msg);
    });


// Glob mode: 
// minifyByGlob walk through the sub directories 
// and looks for all file matching 'filePattern'.
// The 'htmlOut' file for each 'htmlIn' must be specified 
// in an 'node-minify-tag-glob' comment tag
minifyTag.minifyByGlob({
        relativeBaseDir: "../../Xy/",
        filePattern: "**/*.dev.html",
        encoding: "utf8",
        mergeNgIncludes: true
    }, 
    function (err, msg){
        if (err) return reject(err);
        resolve(msg);
    });

HTML comment attributes

Comment tag | Corresponding comment tag | Options -------------------------------- | ---------------------------|--------- node-minify-tag( options ) | node-minify-tag-end | see below node-minify-tag-glob( options ) | none | {"htmlOut": "sample.prod.html"}

Options node-minify-tag

Key | Possible values | Action | File type -------|-----------------------|---------|---------- type | 'no-compress' | concatenation of files | JS / CSS type | 'gcc' | Google Closure Compiler | JS type | 'yui-js' | YUI Compressor | JS type | 'yui-css' | YUI Compressor | CSS type | 'uglifyjs' | UglifyJS | JS type | 'sqwish' | Sqwish | CSS type | 'clean-css' | Clean-css | CSS type | 'csso' | CSSO | CSS fileOut| name of generated (compressed) html or CSS file | - | -

Options node-minify-tag-glob

Key | Possible values | Example ---------|--------------------------------------|------------------- htmlOut | name of generated html file | 'index.prod.html'

As CLI

node node_modules/node-minify-tag/index.js -h

// Explicit mode:
node node_modules/node-minify-tag/index.js -d test/demo/ -i abc.html -o __abc.prod.html 

// glob mode:
node node_modules/node-minify-tag/index.js -g -d test/demo/ -p **/*.dev.html

Information about glob file pattern can be found here: Glob Primer.