The widget loads on demand from a URL. Ideal for lazy loading or CDN integration.
// Dynamically load the widget
function loadDQMWidget(url, fallbackUrl) {
const script = document.createElement('script');
script.src = url;
script.onerror = () => {
// Try fallback URL
const fallback = document.createElement('script');
fallback.src = fallbackUrl;
document.head.appendChild(fallback);
};
document.head.appendChild(script);
}
// Set configuration
window.DQM_CONFIG = { apiKey: '...', websiteId: '...' };
// Start loading
loadDQMWidget(
'https://cdn.example.com/dqm-widget.iife.js',
'/dist/dqm-widget.iife.js'
);
Click the button to load the widget dynamically: