Lazy Condition β‘π ‘π π £π
An if/else that actually skips the branch it doesn't take
- condition
- if_true
- fallback
- *
Most "conditional" setups in ComfyUI aren't really conditional - both branches run, and the switch just decides which output gets passed along afterward. That's wasted compute if one branch is an expensive sampler pass or a heavy node you only sometimes need. This node is different: it uses genuine lazy evaluation, so the branch that doesn't get chosen never executes at all.
Why you'd reach for it
The obvious case is an expensive optional step - say, a second KSampler pass, an upscale, or some heavy postprocessing that you only want to run under certain conditions. Wire it behind a normal switch and ComfyUI still computes it every run, whether or not you use the result, because ComfyUI resolves the whole graph before deciding what to display. Wire it behind LazyCondition instead, and when condition is falsy, that branch is genuinely skipped - no wasted GPU time, no wasted seconds.
The other piece worth knowing about: it remembers. If condition goes falsy and you haven't given it a fallback, it doesn't just return nothing - it returns the last successful if_true result from a previous run. That's specifically there to prevent feedback loops: a common failure mode when a conditional node feeds its own output back into itself is that a falsy condition on one pass produces an empty/null value, which then breaks the next pass that depends on it. This node's whole design is built around avoiding that.
The inputs and output
use_fallback(default false) - when false, a falsy condition returns the last successfulif_trueresult (if one exists yet); when true, it returnsfallbackinstead. This is the switch between "remember the last good value" and "use an explicit alternative."always_execute(default true) - when enabled, the node re-evaluates every run rather than caching.condition(optional, wildcard*type) - anything truthy (non-zero, non-empty, non-None) takes theif_truepath; falsy or unconnected takes the fallback/remembered path.if_true(optional, wildcard) - the branch that's only evaluated - genuinely, lazily - whenconditionis truthy.fallback(optional, wildcard) - used whenconditionis falsy and there's no rememberedif_trueresult yet, or whenuse_fallbackis set.
Output is a single wildcard * - whatever type flows through matches whatever you connected, so it can carry an IMAGE, LATENT, CONDITIONING, or anything else.
How to install it
The pack's README came back empty for install specifics when I checked, so the standard path applies:
ComfyUI Manager: search "RyanOnTheInside", install, restart.
Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/ryanontheinside/ComfyUI_RyanOnTheInside
Restart ComfyUI afterward.
Troubleshooting
If you're not seeing the "skip execution" benefit you expected, check that the expensive node is actually wired into if_true, not just downstream of the condition somewhere else in the graph - lazy evaluation only protects the branch that's structurally behind if_true. If your output seems to be reusing an old value when you expected something fresh, that's the remembered-state behavior working as designed: it happens whenever condition goes falsy with use_fallback left off. If you genuinely want "nothing" rather than a remembered value on a falsy condition, wire an explicit fallback and flip use_fallback to true instead of leaving it to guess.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| use_fallback | BOOLEAN | false | When False, uses last successful if_true result (if one exists). When True, uses fallback value |
| always_execute | BOOLEAN | true | When enabled, the node updates every execution |
| conditionopt | * | When truthy (non-zero, non-empty, non-None), evaluates and returns if_true path. When falsy or unconnected, returns either fallback or previous state of if_true. | |
| if_trueopt | * | The path that should only be evaluated when condition is truthy | |
| fallbackopt | * | Alternative value to use when condition is falsy or no previous state of if_true |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| * | * | β |