#style-sheet #font #query #performance #framework

bin+lib critters-rs

Quickly inline your website's critical CSS

5 releases (stable)

1.1.2 Mar 11, 2025
1.1.0 Dec 31, 2024
1.0.3 Dec 30, 2024
0.1.0 Oct 10, 2024

#10 in #style-sheet

Download history 6/week @ 2024-12-19 316/week @ 2024-12-26 74/week @ 2025-01-02 12/week @ 2025-01-09 3/week @ 2025-01-30 7/week @ 2025-02-06 2/week @ 2025-02-13 3/week @ 2025-02-20 90/week @ 2025-03-06 35/week @ 2025-03-13 3/week @ 2025-03-20

65 downloads per month

Apache-2.0

54KB
1K SLoC

critters_rs

Rapidly inline your site's critical CSS.

Features

  • Extremely fast — written in pure Rust for maximal performance
  • Robust — uses HTML and CSS parsers from the Servo project
  • Integrations with popular frameworks
  • Supports preloading and/or inlining critical fonts
  • Prunes unused CSS keyframes and media queries
  • Minifies CSS using Parcel's lightningcss
  • Supports pruning inlined CSS rules from lazy-loaded stylesheets

Usage

CLI

First, install the critters cli command globally:

cargo install critters-rs

Then, execute critters on a folder with your preferred options,

critters -p ./dist {options}

or view all the possible options:

critters -h

NodeJS API

See the documentation in the package's README.

Rust Crate

View the documentation for the Rust crate at https://docs.rs/critters-rs/.

Other Integrations

View the documentation for other integrations in their package READMEs:

Acknowledgements

This project is heavily inspired by https://github.com/GoogleChromeLabs/critters, aiming to provide identical functionality while offering considerably improved performance. Much credit goes to the Google Chrome team for their work on the original library.

License

Apache 2.0

Dependencies

~18–28MB
~370K SLoC