🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostHTML Plugin Remove Duplicates

This plugin removes duplicated tags. It can be used to remove duplicated css and script tags when your markup is assembling code from different sources.

Before:

<html>
  <body>
    <link rel="stylesheet" type="text/css" href="component.css">
    <div>... component...</div>
    <link rel="stylesheet" type="text/css" href="component.css">
    <div>... component...</div>
  </body>
</html>

After:

<html>
  <body>
    <link rel="stylesheet" type="text/css" href="component.css">
    <div>... component...</div>
    <div>... component...</div>
  </body>
</html>

Install

npm i posthtml posthtml-plugin-remove-duplicates

Usage

const fs = require('fs');
const posthtml = require('posthtml');
const posthtmlPluginRemoveDuplicates = require('posthtml-plugin-remove-duplicates');

posthtml()
    .use(posthtmlPluginRemoveDuplicates({ css: true, js: true }))
    .process(html)
    .then(result => fs.writeFileSync('./after.html', result.html));

Options

  • css: remove duplicated css tags (default false)
  • js: remove duplicated script tags (default false)
  • custom: object or array of objects, with tag (optional) and attribute (mandatory) { tag: 'div', attr: 'data-remove-dup' }

About

A plugin to remove duplicated tags (script and css for example)

Resources

Contributing

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages