IE11 JavaScript (Error: SCRIPT445) "Object doesn't support this action"

object doesn't support this action is error is coming in IE11 using window.dispatchEvent(new Event('resize')); we need to d handle the condition for ie11.

 if (navigator.userAgent.indexOf('MSIE') !== -1 || navigator.appVersion.indexOf('Trident/') > 0) {
                   var evt = document.createEvent('UIEvents');
                   evt.initUIEvent('resize', true, false, window, 0);
                   window.dispatchEvent(evt);
        } else {
                 window.dispatchEvent(new Event('resize'));
        }

There is a race condition in IE that is firing off your script loader callback before the entire script is evaluated. By using setTimeout(initYT, 0) you will allow the script to finish evaluating before firing your initialization function. Glad it worked!