({{, (RefLink[$PreInitialization, paclet:ref/$PreInitialization]) 
is a symbol whose value, if any, is evaluated with (RefLink[ReleaseHold, paclet:ref/ReleaseHold])[$PreInitialization] before any other initializations in a Wolfram Language session.}})

OpenersNotesSection(Spacer1)Details

Persistent values of (RefLink[$PreInitialization, paclet:ref/$PreInitialization]) are typically set with (RefLink[InitializationValue, paclet:ref/InitializationValue])[$PreInitialization]=(RefLink[Hold, paclet:ref/Hold])[expr].

Values defined in different persistence locations on (RefLink[$PersistencePath, paclet:ref/$PersistencePath]) are joined with (RefLink[Flatten, paclet:ref/Flatten]).

Since (RefLink[$PreInitialization, paclet:ref/$PreInitialization]) is used early in the startup of a Wolfram Language session, not all capabilities will already be initialized. For example, remote access such as of the cloud from the desktop will not yet be available.

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Set a value to be evaluated early every time the kernel starts:

InitializationValue[$PreInitialization]=Hold[data=Get["mydata.m"]]

View the current initialization value:

InitializationValue[$PreInitialization]

OpenersExampleSection2(Spacer1)Properties & Relations  (2)

Initialization values are stored in persistent objects:

PersistentObjects["*$PreInitialization"]

List the existing initialization values for (RefLink[$PreInitialization, paclet:ref/$PreInitialization]) in all editable persistence locations:

InitializationObjects[$PreInitialization,{"FrontEndSession","Local","Notebook","Cloud"}]

Remove them:

DeleteObject[Values[%]]

OpenersExampleSection3(Spacer1)Possible Issues  (1)

Create an initialization value for (RefLink[$PreInitialization, paclet:ref/$PreInitialization]) in a nondefault location:

InitializationValue[$PreInitialization,"FrontEndSession"]=Hold[data=Get["mydata.m"]];

(RefLink[Remove, paclet:ref/Remove]) by default removes only the value in the location given by (RefLink[$PersistenceBase, paclet:ref/$PersistenceBase]):

Remove[InitializationValue[$PreInitialization]]

InitializationValue[$PreInitialization]

Remove all values that might exist anywhere in all editable locations given by (RefLink[$PersistencePath, paclet:ref/$PersistencePath]):

Remove[InitializationValue[$PreInitialization,$PersistencePath]]

The default value is still present:

InitializationValue[$PreInitialization]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[InitializationValue, paclet:ref/InitializationValue])  ▪  (RefLink[Initialize, paclet:ref/Initialize])  ▪  (RefLink[$Initialization, paclet:ref/$Initialization])  ▪  (RefLink[$CommandLine, paclet:ref/$CommandLine])  ▪  (RefLink[$EvaluationEnvironment, paclet:ref/$EvaluationEnvironment])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Wolfram System Setup, paclet:guide/WolframSystemSetup])}, {▪(RefLinkPlain[Initialization & Provisioning, paclet:guide/InitializationAndProvisioning])}, {▪(RefLinkPlain[Persistent Storage, paclet:guide/PersistentStorage])}, {▪(RefLinkPlain[Setting Persistent Values, paclet:guide/SettingPersistentValues])}})}})