PurgeCSSPurgeCSS
API Reference
  • English
  • Français
GitHub
API Reference
  • English
  • Français
GitHub
  • PurgeCSS

    • About PurgeCSS
    • Getting Started
    • Configuration
    • Command Line Interface
    • Programmatic API
    • Safelisting
    • Extractors
  • Plugins

    • PostCSS
    • Webpack
    • Gulp
    • Grunt
    • Gatsby
  • Guides

    • Vue
    • React
    • Angular
    • Next.js
    • Nuxt.js
    • Razzle
    • WordPress
    • Hugo
  • Comparison
  • Common Questions

    • How to use with CSS modules
    • How to use with Ant Design

Home > purgecss > Options > dynamicAttributes

Options.dynamicAttributes property

Attributes that are set or changed at runtime, e.g. by JavaScript, and therefore may not appear in the content files. Attribute selectors on these attributes are kept whatever their value. Strings match the attribute name exactly, regular expressions are tested against it.

Signature:

dynamicAttributes: StringRegExpArray;

Example

await new PurgeCSS().purge({
  content: ['index.html'],
  css: ['css/app.css'],
  dynamicAttributes: ['aria-selected', /^data-/]
})