Skip to content

Commit

Permalink
Added support to PurgeCSS (alshedivat#1562)
Browse files Browse the repository at this point in the history
Tackled alshedivat#1329 with [PurgeCSS](https://purgecss.com/).

Being talking with @varuniyer about using
[jekyll-uncss](https://github.com/episource/jekyll-uncss) to reduce css
file sizes by ditching unused classes. This approach have 3 main
problems:

1 - have some limitations as pointed
[here](alshedivat#1329 (comment))
2 - last update to
[jekyll-uncss](https://github.com/episource/jekyll-uncss) was about 3
years ago, so it might have a few issues
3 - [uncss](https://github.com/uncss/uncss) haven't seem a new release
in a while, currently [lacking
maintenance](uncss/uncss#459), and using some
deprecated libraries as seem here:

```
npm install -g uncss
npm WARN deprecated [email protected]: request-promise-native has been deprecated because it extends the now deprecated request package, see request/request#3142
npm WARN deprecated [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: Use your platform's native performance.now() and performance.timeOrigin.
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: request has been deprecated, see request/request#3142
```

I thought about giving PurgeCSS a go, since it has been more [actively
maintaned](https://github.com/FullHuman/purgecss), but
[jekyll-purgecss](https://github.com/mhanberg/jekyll-purgecss) haven't.

For this, I needed to change to use some local libraries instead of
getting them via CDN. The good news is that it is quite effective in
reducing css file sizes. Comparing dir sizes with `du -hs
_site/assets/css/`:

| current | minify | PurgeCSS | PurgeCSS + minify |
| ------- | ------ | -------- | ----------------- |
| 1,1M    | 988K   | 456K     | 420K              |

---------

Signed-off-by: George Araujo <[email protected]>
  • Loading branch information
george-gca authored Sep 28, 2023
1 parent f896d15 commit 8effb2d
Show file tree
Hide file tree
Showing 52 changed files with 147 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Git LFS file not shown
4 changes: 2 additions & 2 deletions README.md
Git LFS file not shown
4 changes: 2 additions & 2 deletions _config.yml
Git LFS file not shown
4 changes: 2 additions & 2 deletions _includes/head.html
Git LFS file not shown
4 changes: 2 additions & 2 deletions _includes/scripts/bootstrap.html
Git LFS file not shown
4 changes: 2 additions & 2 deletions _includes/scripts/misc.html
Git LFS file not shown
4 changes: 2 additions & 2 deletions _sass/_variables.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_animated.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_bordered-pulled.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_core.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_fixed-width.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_functions.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_icons.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_list.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_mixins.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_rotated-flipped.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_screen-reader.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_shims.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_sizing.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_stacked.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/_variables.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/brands.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/fontawesome.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/regular.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/solid.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions _sass/font-awesome/v4-shims.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/academicons.min.css
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/bootstrap-toc.min.css
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/bootstrap.min.css
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/bootstrap.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/css/jekyll-pygments-themes-github.css
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/jekyll-pygments-themes-native.css
Git LFS file not shown
4 changes: 2 additions & 2 deletions assets/css/main.scss
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/mdb.min.css
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/css/mdb.min.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/fonts/academicons.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/fonts/academicons.woff
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/js/bootstrap-toc.min.js
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/js/bootstrap.bundle.min.js
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/js/bootstrap.bundle.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/js/mdb.min.js
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/js/mdb.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions assets/webfonts/fa-brands-400.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-brands-400.woff2
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-regular-400.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-regular-400.woff2
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-solid-900.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-solid-900.woff2
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-v4compatibility.ttf
Git LFS file not shown
3 changes: 3 additions & 0 deletions assets/webfonts/fa-v4compatibility.woff2
Git LFS file not shown
4 changes: 2 additions & 2 deletions bin/deploy
Git LFS file not shown
3 changes: 3 additions & 0 deletions purgecss.config.js
Git LFS file not shown

0 comments on commit 8effb2d

Please sign in to comment.