MCPcopy Index your code
hub / github.com/ampproject/amphtml / warmupDynamic

Function warmupDynamic

ads/alp/handler.js:182–200  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

180 * @visibleForTesting
181 */
182export function warmupDynamic(e) {
183 const link = getLinkInfo(e);
184 if (!link || !link.eventualUrl) {
185 return;
186 }
187 // Preloading with empty as and newly specced value `fetch` meaning the same
188 // thing. `document` would be the right value, but this is not yet supported
189 // in browsers.
190 const linkRel0 = /*OK*/ document.createElement('link');
191 linkRel0.rel = 'preload';
192 linkRel0.href = link.eventualUrl;
193 const linkRel1 = /*OK*/ document.createElement('link');
194 linkRel1.rel = 'preload';
195 linkRel1.as = 'fetch';
196 linkRel1.href = link.eventualUrl;
197 const head = getHeadOrFallback(e.target.ownerDocument);
198 head.appendChild(linkRel0);
199 head.appendChild(linkRel1);
200}
201
202/**
203 * Return <head> if present or just the document element.

Callers 1

Calls 2

getLinkInfoFunction · 0.85
getHeadOrFallbackFunction · 0.85

Tested by

no test coverage detected