MCPcopy
hub / github.com/ampproject/amphtml / startRegisterOrChunk

Function startRegisterOrChunk

src/runtime.js:312–328  ·  view source on GitHub ↗

* @param {!Window} global Global scope to adopt. * @param {function(!Object, !Object)|!ExtensionPayload} fnOrStruct * @param {function()} register

(global, fnOrStruct, register)

Source from the content-addressed store, hash-verified

310 * @param {function()} register
311 */
312function startRegisterOrChunk(global, fnOrStruct, register) {
313 if (typeof fnOrStruct == 'function' || fnOrStruct.p == 'high') {
314 // "High priority" extensions do not go through chunking.
315 // This should be used for extensions that need to run early.
316 // One example would be viewer communication that is required
317 // to transition document from pre-render to visible (which
318 // affects chunking itself).
319 // We consider functions as high priority, because
320 // - if in doubt, that is a better default
321 // - the only actual user is a viewer integration that should
322 // be high priority.
323 Promise.resolve().then(register);
324 } else {
325 register.displayName = fnOrStruct.n;
326 startupChunk(global.document, register);
327 }
328}
329
330/**
331 * Applies the runtime to a given global scope for a single-doc mode.

Callers 1

installExtensionFunction · 0.85

Calls 3

startupChunkFunction · 0.90
resolveMethod · 0.80
thenMethod · 0.45

Tested by

no test coverage detected