Let's cut the fluff. If you are still shipping massive JavaScript bundles just to calculate CSS styles in the browser, you are bottlenecking your Core Web Vitals. Let's look at how to handle styling at compile time, completely stripping out the runtime overhead.
The entry point for this architecture in traceless-style is the tl.create API. It accepts a single argument: an object where the keys are arbitrary names you choose, and the values are literal style definitions.
Here is exactly what defining a component looks like:
javascript
import { tl } from "traceless-style";
const $ = tl.create({
card: {
display: "flex",
flexDirection: "column",
padding: "1rem",
background: "#ffffff",
borderRadius: "8px",
boxShadow: "0 1px 3px rgba(0,0,0,0.1)",
_hover: {
boxShadow: "0 4px 12px rgba(0,0,0,0.15)",
},
title: {
fontSize: "1.25rem",
fontWeight: 600,
marginBottom: "0.5rem"
What makes this powerful is what happens next. A strict literal-only AST parser locates the tl.create call at build time, validates properties against a strict allowlist, and hashes each property-value pair into an 8-character base36 class name.
After compilation, the object above is entirely stripped from your bundle and replaced with pure string hashes:`
javascript
// After compilation:Because the compiler needs to know every value at compile time to emit the matching CSS rule, dynamic variables are strictly rejected. If you try to pass color: myColor or use a template literal, the parser will throw a ParseError. If you need dynamic values, you use compile-time resolved design tokens (tl.defineTokens), not runtime JavaScript.
const $ = {
card: "tl12abcd34 tl56efgh78 tl9ab0c1d2 tl3e4f5g6h tl7i8j9k0l tlmnopqrst tluvwxyz12",
title: "tl34567890 tlabcdefgh tlijklmnop",
};
You also get full composition and built-in variants as standard object keys. Pseudo-classes, breakpoints, and dark mode overrides are handled instantly:
javascript
tl.create({ Pre-compile it, hash it, and ship zero runtime. Have you migrated your frontend stack to strict build-time styling yet?
myStyle: {
color: "white",
_hover: { color: "lightblue" },
sm: { padding: "0.5rem" }, // breakpoint
_dark: { background: "black" }, // dark mode override
"&:nth-child(odd)": { background: "#f0f0f0" }, // raw selector pass-through
},
});
https://github.com/sparkgoldentech/traceless-style/blob/main/docs/api/create.md
Top comments (0)