Prevent Dynamic from behaving dynamically until notebook evaluated
You can use the SaveDefinitions
option of DynamicModule
for this:
DynamicModule[{}, Dynamic@a[[2]], SaveDefinitions -> True]
To start your notebook with Dynamic Updating Enabled
not being checked add this code to your notebook:
Dynamic[, Initialization :> FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]]]
To return the dynamic updating back, you should use ToggleDynamicUpdating
again, as you correctly mentioned in the comments:
FrontEndExecute[FrontEndToken["ToggleDynamicUpdating"]]
a = {1, 2};
Dynamic[a[[2]]]
Alternatively, you could program not to save output cells when you close your notebook according to this procedure. No output - no issues with dynamic update =)
Just returning to this question now and after reading your addendum I don't think you have adequately set up your test. For example here we see that when the kernel stops the value of a
is not preserved and you get error boxes appearing:
If you want a
to be Global then try this:
Dynamic@If[ListQ[a] &&Length[a]>1&& TrueQ[a[[1]] > 0], Dynamic[a[[2]]], Spacer[0]]
It is best to localise your dynamic variables rather than have them global. In order to localise the variable and have its value stored within the notebook you need to make it a DynamicModule
variable ...which you haven't done in any of your examples. If it is a DM variable then it will "survive" the kernel session.