{"version":"1.0","type":"rich","title":"Wait for an element to exist. ES6, Promise, MutationObserver","description":"This example demonstrates a utility for resolving race conditions in web applications by waiting until an element matching a given selector exists in the DOM, then returning a promise that resolves with that element. The code uses native ES6 Promises and the MutationObserver API to monitor the document’s root element for child list and subtree changes. When the target element appears, the observer disconnects and the promise resolves, allowing actions like removing the widget. The accompanying usage example shows how to delete `#someWidget` once it is present.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-3f973212ef932fabf1690d465b2a77a0?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}