Skip to content

Instantly share code, notes, and snippets.

@frnwtr
Last active May 7, 2021 02:04
Show Gist options
  • Save frnwtr/5647673bb15ca8893642469d3b400cba to your computer and use it in GitHub Desktop.
Save frnwtr/5647673bb15ca8893642469d3b400cba to your computer and use it in GitHub Desktop.
const WordpressPurgeCSS = {
whitelist: [
"rtl",
"home",
"blog",
"archive",
"date",
"error404",
"logged-in",
"admin-bar",
"no-customize-support",
"custom-background",
"wp-custom-logo"
],
whitelistPatterns: [
/^search(-.*)?$/,
/^(.*)-template(-.*)?$/,
/^(.*)?-?single(-.*)?$/,
/^postid-(.*)?$/,
/^attachmentid-(.*)?$/,
/^attachment(-.*)?$/,
/^page(-.*)?$/,
/^(post-type-)?archive(-.*)?$/,
/^author(-.*)?$/,
/^category(-.*)?$/,
/^tag(-.*)?$/,
/^tax-(.*)?$/,
/^term-(.*)?$/,
/^(.*)?-?paged(-.*)?$/
]
};
@adampatterson
Copy link

Thanks @bfiessinger, I will try it out. I ended up hunting through the code for a lot of the elements.

@ankurdhiman89
Copy link

ankurdhiman89 commented May 18, 2020

Please give me some link from where i get the information where i add this file in theme file or in root file
please tell me where i add this code {
import Purgecss from 'purgecss'
import purgecssWordpress from 'purgecss-with-wordpress'
const purgeCss = new Purgecss({
content: ['/*.html'],
css: ['
/*.css'],
whitelist: purgecssWordpress.whitelist,
whitelistPatterns: purgecssWordpress.whitelistPatterns
})
const result = purgecss.purge()
}
how i run this code
please help me?
thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment