As a newcomer to programming, I recently came across this code from an open source project.
I am in the process of loading a widget onto a website. Instead of having the widget load instantly, I would like it to wait 10 seconds before displaying.
Below is the method I am using to load the widget:
Code snippet provided below....
switch (methodName) {
case 'init':
const loadedObject = Object.assign(defaultConfig, item[1]);
// actual rendering of the widget
const wrappingElement =
loadedObject.element ?? win.document.body;
targetElement = wrappingElement.appendChild(
win.document.createElement('div')
);
targetElement.setAttribute('id', `widget-${instanceName}`);
render(targetElement, loadedObject);
// store indication that widget instance was initialized
win[`loaded-${instanceName}`] = true;
break;
default:
console.warn(`Unsupported method [${methodName}]`, item[1]);
}
}