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

Function getContainerScript

3p/yotpo.js:10–25  ·  view source on GitHub ↗

* Get the correct script for the container. * @param {!Window} global * @param {string} scriptSource The source of the script, different for post and comment embeds. * @param {string} widgetType The type of the widget being instantiated. * @param {function(!Object, string)} cb

(global, scriptSource, widgetType, cb)

Source from the content-addressed store, hash-verified

8 * @param {function(!Object, string)} cb
9 */
10function getContainerScript(global, scriptSource, widgetType, cb) {
11 loadScript(global, scriptSource, () => {
12 global.Yotpo = global.Yotpo || {};
13 if (widgetType !== 'ReviewsTab') {
14 delete global.Yotpo.widgets['testimonials'];
15 }
16 const yotpoWidget =
17 typeof global.yotpo === 'undefined' ? undefined : global.yotpo;
18 yotpoWidget.on('CssReady', function () {
19 cb(yotpoWidget, 'cssLoaded');
20 });
21 yotpoWidget.on('BatchReady', function () {
22 cb(yotpoWidget, 'batchLoaded');
23 });
24 });
25}
26
27/**
28 * Create DOM element for the Yotpo bottom line plugin:

Callers 1

yotpoFunction · 0.70

Calls 3

loadScriptFunction · 0.90
cbFunction · 0.50
onMethod · 0.45

Tested by

no test coverage detected