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.