fix(core): run script when DOM is ready

Sometimes the scripts start to run before DOM is fully ready. It causes things
like #475 where the checkbox is not in DOM yet but the script is already asking for it.
This commit is contained in:
alistair3149 2022-06-04 17:42:06 -04:00
parent 9d8a631f44
commit eba22354e5
No known key found for this signature in database
GPG key ID: 94D081060FD3DD9C

View file

@ -117,4 +117,10 @@ function main( window ) {
mw.loader.load( 'skins.citizen.preferences' );
}
if ( document.readyState === 'interactive' || document.readyState === 'complete' ) {
main( window );
} else {
document.addEventListener( 'DOMContentLoaded', function () {
main( window );
} );
}