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

Method performPreload_

src/preconnect.js:229–248  ·  view source on GitHub ↗

* Performs a preload using ` `. * @param {string} url * @private

(url)

Source from the content-addressed store, hash-verified

227 * @private
228 */
229 performPreload_(url) {
230 const preload = htmlFor(this.document_)`
231 <link rel="preload" referrerpolicy="origin" />`;
232 preload.setAttribute('href', url);
233 // Do not set 'as' attribute to correct value for now, for 2 reasons
234 // - document value is not yet supported and dropped
235 // - script is blocked due to CSP.
236 // Due to spec change we now have to also preload with the "as"
237 // being set to `fetch` when it would previously would be empty.
238 // See https://github.com/w3c/preload/issues/80
239 // for details.
240 if (this.features_.onlyValidAs) {
241 preload.as = 'fetch';
242 } else {
243 preload.as = '';
244 }
245 this.head_.appendChild(preload);
246 // As opposed to preconnect we do not clean this tag up, because there is
247 // no expectation as to it having an immediate effect.
248 }
249
250 /**
251 * Skips over non HTTP/HTTPS URL.

Callers 1

preloadMethod · 0.95

Calls 2

htmlForFunction · 0.90
setAttributeMethod · 0.45

Tested by

no test coverage detected