Stoop
GitHub
/

warmCache

Pre-compile CSS objects to warm the cache and eliminate FOUC

Usage

import { warmCache } from "./theme";

warmCache([
  {
    padding: "$medium",
    backgroundColor: "$primary",
  },
  {
    color: "$text",
    fontSize: "$large",
  },
]);

Parameters

ParameterTypeDescription
stylesCSS[]Array of CSS objects to pre-compile

Purpose

warmCache pre-compiles CSS objects before they're used:

Example

Pre-compile common component styles:

import { warmCache } from "./theme";

// Pre-compile common styles
warmCache([
  // Button styles
  {
    padding: "$medium $large",
    borderRadius: "$default",
    cursor: "pointer",
  },
  // Card styles
  {
    padding: "$large",
    borderRadius: "$default",
    backgroundColor: "$background",
  },
  // Container styles
  {
    maxWidth: "1000px",
    margin: "0 auto",
    padding: "$medium",
  },
]);

Notes