Is it possible to tell DynamicBox to not run its very first dynamic evaluation when it appears on screen, and instead, to just show its CachedValue? Consider the following example:


Dynamic[Pause[2];a, SynchronousUpdating -> False, CachedValue -> "1"]

The CachedValue is first used so it displays the 1. But it also triggers a dynamic evaluation (evidenced by 2 seconds of highlighted cell bracket).

Obviously the first evaluation is unnecessary since the developer has already provided the correct starting value in CachedValue.

How do I prevent that very first dynamic evaluation? All subsequent dynamic updating should occur.

  • 1
    $\begingroup$ I don't like to count on Dynamic for more than displaying content so I'd do Dynamic[ aView] and mutate aView as/when I see fit. $\endgroup$
    – Kuba
    Mar 31, 2023 at 7:13
  • $\begingroup$ I don't understand exactly what you mean by "first evaluation". If you have a notebook with a Dynamic expression in an input cell, but you never evaluate the input cell, then that Dynamic will never be evaluated. To get the actual dynamic "thingy", you need to evaluate the Dynamic expression, so you need to evaluate that cell. And once you evaluate it, Mathematica will need to do "all the stuff" to set up the dynamic "thingy". How could it avoid doing that? $\endgroup$
    – lericr
    Apr 5, 2023 at 16:48
  • $\begingroup$ Is there any extra context you could provide that would clarify what your objective is? I personally am having a hard time imagining why the behavior here would cause problems. I'm having a hard time imagining a scenario where I would want to avoid a "first evaluation" of a dynamic display. $\endgroup$
    – lericr
    Apr 5, 2023 at 16:50
  • $\begingroup$ Are you wanting some symbol other than a to trigger the dynamic update? For that there is the TrackedSymbols option. $\endgroup$
    – lericr
    Apr 5, 2023 at 16:52


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.