DEV Community

Cover image for πŸš€ Install and Use FSCSS
FSCSS tutorial
FSCSS tutorial

Posted on

πŸš€ Install and Use FSCSS

πŸš€ Install and Use FSCSS (v1.1.7)

FSCSS (Figured Shorthand Cascading Style Sheets) introduces shorthand features that make writing CSS faster, smarter, and more dynamic.

You can use FSCSS via CDN for quick tests or compile to CSS for large production projects.


πŸ“¦ Installation

Install via NPM (Recommended for projects):

npm install -g fscss
Enter fullscreen mode Exit fullscreen mode

This installs FSCSS globally so you can use the fscss command anywhere.


βš™οΈ Compiling FSCSS β†’ CSS

For large-scale or production projects, you should compile FSCSS into CSS before deploying.

Example:

fscss style.fscss style.css
Enter fullscreen mode Exit fullscreen mode
  • style.fscss β†’ your shorthand stylesheet
  • style.css β†’ the compiled standard CSS output. Example linked the style.css to html:
<link rel="stylesheet" href="style.css">
Enter fullscreen mode Exit fullscreen mode

πŸ‘‰ This ensures faster load times, better performance, and no runtime overhead.


🌐 Option 2: CDN Runtime (For quick tests & prototypes)

If you just want to experiment or add dynamic runtime styles, you can load FSCSS from CDN:

<script src="https://cdn.jsdelivr.net/npm/fscss@1.1.7/e/exec.min.js" defer></script>
<link type="text/fscss" href="style.fscss">
Enter fullscreen mode Exit fullscreen mode

This way, FSCSS runs directly in the browser β€” but it’s not recommended for big projects.


🎲 Runtime Example

FSCSS runtime is required whenever you use features that need randomization or loops at runtime:

/ Example: Randomized display /
.post {
  display: @random([block, none]);
}
Enter fullscreen mode Exit fullscreen mode
  • When compiled, @random() resolves to a fixed value.
  • With runtime, it randomizes every page load without extra JavaScript.

πŸ“Š CDN vs CLI Usage

Use Case Recommended Method Why
Quick tests, demos, small apps CDN runtime No setup required, works instantly
Large/production projects CLI compile Faster load, optimized CSS, no runtime overhead
Dynamic styles (random, loops) CDN runtime Needed for non-deterministic behavior

✨ Best Practices

  • βœ… Use CLI compile (fscss style.fscss style.css) for production
  • βœ… Use CDN runtime only when dynamic/non-deterministic styles are required
  • βœ… Always compile + minify CSS before deploying
  • βœ… Avoid inline // comments (use / ... /)
  • βœ… Keep FSCSS files modular and organized

πŸ‘‰ Try the online compiler: Upload FSCSS & Compiler

Top comments (0)