I’m new to programming and the following code I got through an open source project.
I’m loading a widget on a website. So instead of immediately loading the widget, I want it to take 10 secs before showing the widget.
I was wondering what is the right way to achieve it?
Entire code below…………
switch (methodName) {
case 'init':
const loadedObject = Object.assign(defaultConfig, item[1]);
// the 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]);
}
}