MCPcopy Create free account
hub / github.com/ampproject/amphtml / constructor

Method constructor

src/preconnect.js:64–96  ·  view source on GitHub ↗

* @param {!Window} win

(win)

Source from the content-addressed store, hash-verified

62 * @param {!Window} win
63 */
64 constructor(win) {
65 /** @private @const {!Document} */
66 this.document_ = win.document;
67
68 /** @private @const {!Element} */
69 this.head_ = dev().assertElement(win.document.head);
70 /**
71 * Origin we've preconnected to and when that connection
72 * expires as a timestamp in MS.
73 * @private @const {!{[key: string]: number}}
74 */
75 this.origins_ = {};
76 /**
77 * Urls we've prefetched.
78 * @private @const {!{[key: string]: boolean}}
79 */
80 this.urls_ = {};
81 /** @private @const {!./service/platform-impl.Platform} */
82 this.platform_ = Services.platformFor(win);
83 // Mark current origin as preconnected.
84 this.origins_[parseUrlDeprecated(win.location.href).origin] = true;
85
86 /**
87 * Detect support for the given resource hints.
88 * Unfortunately not all browsers support this, so this can only
89 * be used as an affirmative signal.
90 * @private @const {!PreconnectFeaturesDef}
91 */
92 this.features_ = getPreconnectFeatures(win);
93
94 /** @private @const {!./service/timer-impl.Timer} */
95 this.timer_ = Services.timerFor(win);
96 }
97
98 /**
99 * Preconnects to a URL. Always also does a dns-prefetch because

Callers

nothing calls this directly

Calls 4

devFunction · 0.90
parseUrlDeprecatedFunction · 0.90
getPreconnectFeaturesFunction · 0.85
assertElementMethod · 0.80

Tested by

no test coverage detected