Skip to content

Yuriy-Svetlov/html-minifier-without-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HTMLMinifier-Without-js

You probably want to use original lib - https://github.com/kangax/html-minifier

Get started

Install

npm i html-minifier-without-js

Example 1

import { minify } from 'html-minifier-without-js/src/htmlminifier.js'


let htmlSource = '<div id="home_con-h1">                  <h1>TEST H1</h1>                            <h2>TEST H2</h2></div>                <p title="blah" id="moo">    foo       </p>';
var result = minify(htmlSource, 
{
    collapseWhitespace: true, //удаляем пустые пространства между тегами
    removeComments: true, //удаляем коментарии
    removeScriptTypeAttributes: true, //Remove type="text/javascript" from script tags. Other type attribute values are left intact
    includeAutoGeneratedTags: false,
    ignoreCustomComments: [ // ignore noindex comments
        /^noindex/,
        /\/noindex+$/
    ], 
    minifyCSS: true, //минифицирует JS
    trimCustomFragments: true, //Удаляет пустой пространство около игнорируемых элементов
    //ignoreCustomFragments: [ (/\{\%[^\%]*?\%\}(\s)?/g) ], //Игнорирования тега
});

console.log(result);

About

You probably want to use original lib - https://github.com/kangax/html-minifier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published