Understanding exec() in FSCSS — Two Completely Different Jobs

Understanding exec() in FSCSS — Two Completely Different Jobs

●1 ●24 ●62
calendar_today • schedule1 min read

Understanding exec() in FSCSS

In FSCSS, exec() serves two completely different purposes depending on where you write it:

  1. Inside your stylesheet: as a utility / debugging function
  2. In JavaScript / HTML: to load and compile the styles

Let’s break both down clearly.


1. Inside Stylesheets: Debugging & Logging

When used inside an @event block or after processing an array, exec() lets you run small JavaScript helpers directly from your CSS.
Its main job here is printing debug information to the browser console so you can check if your logic is working.

Console Logging

You can pass flags like _log, _warn, _info, or _error:

@event scaleSize(e) {
  if e >= 8 {
    return| num(8*2)em exec(_log, "Scaling to 16em for optimal readability")
  }
}

Checking Array Data

You can also inspect the current values inside an FSCSS array:

@arr fruits[ apple, orange, banana ]

/* Prints: apple orange banana straight to your browser console */
exec(_log, "@arr.fruits")

This is extremely useful while building complex logic with @event, @arr, or calculated values.


2. In JavaScript & Imports: Compilation Engine

Outside the stylesheet, exec is the core engine that compiles and runs FSCSS source code.

CDN Initialization (HTML)

The compiler file loaded via CDN is named exec.min.js:

<script src="https://cdn.jsdelivr.net/npm/fscss@1.1.25/exec.min.js" defer></script>

<style>
  /* Tells the engine to execute the initialization for a module */
  @import(exec(_init circle-progress))
</style>

Programmatic JavaScript Usage

You can also import and control the compiler directly from JavaScript:

import { exec } from "https://cdn.jsdelivr.net/npm/fscss@1.1.25/e/xfscss.min.js";

new exec({
  type: "URL",
  content: "styles.fscss",
  onSuccess: "Styles loaded successfully!",
  onError: "Oops, style compilation failed!"
});

This gives you full control over loading, success messages, and error handling.


Quick Summary

Location Purpose Common Use Case
Inside .fscss Debugging & console logging Check @event logic or array values
In HTML / JavaScript Compile and run FSCSS Load styles or initialize modules

Two different jobs. Same name.
Once you know the context, exec() becomes much clearer.


Useful links

Want more #javascript & #css deep dives?

Join 5,999+ developers sharing real benchmarks, code breakdowns, and projects. Free forever.

2 Comments

1 vote
0

More Posts

FSCSS v1.2.0 is out: two clean entry points, full backward compatibility, and inline

Figsh - Sep 5

I built pure CSS 3D dice cube module: FSCSS

Figsh - Aug 7

FSCSS layout helpers: stack, hstack, center, size, rounded, ratio-fit(), etc

Figsh - Oct 21

Building Circular UI with circle-progress.fscss (No JavaScript)

Figsh - Sep 13

Designing Stats UIs with FSCSS and st-core

Figsh - Apr 4
chevron_left
1.8k Points • 87 Badges
27Posts
18Comments
14Connections
A full-stack web developer: Building smart solutions, designing meaningful experiences, and continuo... Show more

Related Jobs

View all jobs →

Commenters (This Week)

1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!