A posthtml A posthtml plugin for removing tags
Essential for removing unwanted or tags do not pass validation
npm i -S posthtml posthtml-remove-tags
Note: This project is compatible with node v4+
import {readFileSync, writeFileSync} from 'fs';
import posthtml from 'posthtml';
import removeTags from 'posthtml-remove-tags';
const html = readFileSync('input.html', 'utf8');
posthtml()
.use(removeTags({tags: ['style', 'script']}))
.process(html)
.then(result => {
writeFileSync('output.html', result.html);
});
Returns the html without the tags listed in option
<!DOCTYPE html>
<head><style></style></head>
<!DOCTYPE html>
<head></head>
Type: Array
Default: []
Description: The list of tags to be deleted