JSPM

html-attributes-remover

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 12
  • Score
    100M100P100Q43942F
  • License ISC

Remove html attributes like css classes, inline css, id from html

Package Exports

  • html-attributes-remover

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (html-attributes-remover) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Html Attributes Remover

About this Package

Provide a list of attributes you need to remove from provided html or selective tags of html

Install:

npm install html-attributes-remover

Remove html attributes like style, class from div tags

const AttributeRemover = require('html-attributes-remover').default
const attributeRemover   = new AttributeRemover({
  "htmlTags": ["div"],
  "attributes": ["style", "class"]
})

let html    = "<div class='row' style='color:red;'><p><span style='font-size:100;'>Hello there!</span></p></div>"
let newHtml = attributeRemover.remove(html)
console.log(newHtml) // "<div><p><span style='font-size:100;'>Hello there!</span></p></div>"

If you want to remove attributes from all html tags then do not mention any htmlTags while initializing the AttributeRemover class