Stylus mixin expansion and compiled CSS output size
0 reputation · 01 Jul 2023, 21:10 UTC
Stylus supports mixins for reusable groups of declarations, with optional arguments for dynamic generation. The compiler expands mixins at build time, so each call is inlined into the output.
The design goal is to understand the trade-off between source convenience and final CSS size when mixins are reused across selectors. Silent mixins provide logic-only abstractions, while regular mixins contribute directly to output.
There is an unresolved decision about when mixin reuse creates acceptable duplication versus when a native CSS class or silent mixin is preferable for size control, especially with deep nesting.
What criteria distinguish a mixin that should be expanded versus one that should be refactored to a class? Does argument variation increase duplication in the compiled output? Is there documented guidance for balancing nesting depth with output readability?