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

Function bootstrap

src/amp.js:49–91  ·  view source on GitHub ↗

* Execute the bootstrap * @param {!./service/ampdoc-impl.AmpDoc} ampdoc * @param {!./service/performance-impl.Performance} perf

(ampdoc, perf)

Source from the content-addressed store, hash-verified

47 * @param {!./service/performance-impl.Performance} perf
48 */
49function bootstrap(ampdoc, perf) {
50 startupChunk(self.document, function services() {
51 // Core services.
52 installRuntimeServices(self);
53 installAmpdocServices(ampdoc);
54 // We need the core services (viewer/resources) to start instrumenting
55 perf.coreServicesAvailable();
56 maybeTrackImpression(self);
57 });
58 startupChunk(self.document, function adoptWindow() {
59 adoptWithMultidocDeps(self);
60 });
61 startupChunk(self.document, function builtins() {
62 // Builtins.
63 installBuiltinElements(self);
64 });
65 startupChunk(self.document, function stub() {
66 // Pre-stub already known elements.
67 stubElementsForDoc(ampdoc);
68 whenDocumentComplete(self.document).then(() => markUnresolvedElements());
69 });
70 startupChunk(
71 self.document,
72 function final() {
73 if (!IS_SXG) {
74 installPullToRefreshBlocker(self);
75 }
76 installAutoLightboxExtension(ampdoc);
77 installStandaloneExtension(ampdoc);
78 maybeValidate(self);
79 makeBodyVisible(self.document);
80 preconnectToOrigin(self.document);
81 },
82 /* makes the body visible */ true
83 );
84 startupChunk(self.document, function finalTick() {
85 perf.tick(TickLabel_Enum.END_INSTALL_STYLES);
86 Services.resourcesForDoc(ampdoc).ampInitComplete();
87 // TODO(erwinm): move invocation of the `flush` method when we have the
88 // new ticks in place to batch the ticks properly.
89 perf.flush();
90 });
91}
92
93// Store the originalHash as early as possible. Trying to debug:
94// https://github.com/ampproject/amphtml/issues/6070

Callers 1

amp.jsFile · 0.85

Calls 15

startupChunkFunction · 0.90
installRuntimeServicesFunction · 0.90
installAmpdocServicesFunction · 0.90
maybeTrackImpressionFunction · 0.90
adoptWithMultidocDepsFunction · 0.90
installBuiltinElementsFunction · 0.90
stubElementsForDocFunction · 0.90
whenDocumentCompleteFunction · 0.90
markUnresolvedElementsFunction · 0.90

Tested by

no test coverage detected