What is the fastest way to wait/check for _spPageContextInfo to be initialized?
I use AdditionalPageHead so my scripts are loaded before _spPageContextInfo is set.
Here are some alternatives, some I have already tried (single specific system, don't use these numbers as references):
jQuery(document)ready: 300ms - 400ms._spBodyOnLoadFunctions.push: 300ms - 400ms.- Polling with
setInterval: 10ms - 30ms.
Notes: I don't want to use setInterval, even though I use clearInterval. Despite what some sites say, ExecuteOrDelayUntilBodyLoaded, at least with sp.js, can in some instances actually (probably when cached) load before _spPageContextInfo is set. I'm skeptical to defer-attribute, and I believe async-attribute can also load too fast - not very robust.
_spPageContextInfodefined in the main request along with the HTML? In which case you'd need to wait for it to load?<script>_spPageContextInfo={...}</script>, which is placed later in the markup than my normal<script src=".."></script>, which again means it is evaluated at a later time in the DOM - and yes, I must indeed Wait for _spPageContextInfo to initialize, but what is the fastest and ultimately the best way to do this?