But Plot[Sin[x], {x, 0, 2 Pi}, PlotStyle -> Black]
has no n
in it. So it does not depend on dynamics of n
changing at all.
If you show an example of what is it you are trying to optimize, it will help.
i.e. it is the same as if you wrote
DynamicModule[{n = 1, m = Plot[Sin[x], {x, 0, 2 Pi}, PlotStyle -> Black]},
Row[{Slider[Dynamic[n], {0, 2 Pi}],
Dynamic@Show[m,Plot[Sin[x], {x, 0, n}, PlotStyle -> Red]]}]]
Dynamic
can not be inside Show
, since it is not graphics object, so has to be outside Show
.
But again, if you show an example where it matters, it will help, since in your example, the first plot has no dynamics in it, so it will not affect the performance.