html-slim
v0.1.3
Published
A utility to slim down HTML by removing spaces, comments, tags and attributes.
Downloads
557
Readme
html-slim
A utility to slim down HTML by removing spaces, comments, tags and attributes.
SYNOPSIS
import {slim} from "html-slim";
const slimFn = slim({
// CSS selector for removing tags
selector: "body > header, body > footer",
// RegExp for removing tags, attributes and class tokens
tag: /^(next-|nextjs-)/,
attr: /^data-v-/,
className: /^_\w{7}$/,
// shortcut for removing scripts and styles
script: true,
ldJson: false,
style: true,
// removing spaces and comments per default
space: true,
comment: true,
});
const compactHtml = slimFn(originalHtml);COMMONJS
const {slim} = require("html-slim");BROWSERS
<script src="https://unpkg.com/html-slim/dist/html-slim.min.js"></script>
<script>
const slimFn = slim({})
const html = slimFn(document.documentElement.outerHTML);
console.log(html);
</script>TYPESCRIPT
See TypeScript declaration index.d.ts for detail.
LINKS
- https://github.com/kawanet/html-slim
- https://www.npmjs.com/package/html-slim
