extract_critical_css

Function extract_critical_css 

Source
pub fn extract_critical_css(
    css: &str,
    html: Option<&str>,
    route: Option<&str>,
) -> String
Expand description

Extract critical CSS from a stylesheet based on HTML content

This function:

  • Parses the HTML to identify above-the-fold elements
  • Matches CSS rules to those elements
  • Extracts only the relevant CSS rules

§Arguments

  • css - The full CSS stylesheet
  • html - The HTML content to analyze (optional, if None, extracts common critical patterns)
  • route - Optional route identifier for route-specific extraction

§Returns

The critical CSS string containing only rules needed for above-the-fold content