Widget best practises for web developers
Widget DOM best practices
The widget script loads asynchronously which means it will appear in the DOM at some point in the future depending on network performance and other variable factors. For normal situations this has no effect but when the DOM is dynamically modified this might cause some problems.
Example situations that need attention:
- Widget is rendered, stored in DOM and displayed or moved in the DOM dynamically. This might cause problems in case the widget has not finished loading and rendering before it is stored or removed from DOM.
To avoid problems with the widget not being properly rendered in the DOM read the following:
- Use
<div>
embedding on dynamically changing DOM, e.g. React. The script will detect DOM changes and renders the widgets as the div elements appear in the DOM. - Avoid rendering the widgets when they will not be needed (seen by a human). This also reduces widget views which will be counted for even if the widget is not visible on the screen.
Updated on: 17/09/2025
Thank you!