GoogleChromeLabs / critters

🦔 A Webpack plugin to inline your critical CSS and lazy-load the rest.
https://npm.im/critters-webpack-plugin
Apache License 2.0
3.42k stars 108 forks source link

Feature Request: Caching CSS Based on Data-Attribute #169

Open akshaymhk opened 2 months ago

akshaymhk commented 2 months ago

Implement a feature to cache CSS based on a data attribute (e.g., data-pagetype). This will optimize the process by caching critical CSS, thereby improving the Time to First Byte (TTFB).

Proposed Solution:

1. Enable Feature:

2. HTML Structure:

3. Unique Key:

4. Cache Implementation:

Benefits:

Example Usage:

<div class="page_layout_nxt" data-pagetype="homepage_loggedin_mobile"> <!-- Page content --> </div>

When cacheCriticalCSS is set to true, the critical CSS for this specific data-pagetype will be cached and reused for subsequent requests with the same unique key.

Pull Request:

https://github.com/GoogleChromeLabs/critters/pull/168