function whenDOMReady() {
		return new Promise(function(resolve) {
			function onLoaded() {
				document.removeEventListener( "DOMContentLoaded", onLoaded, false );
				resolve();
			}

			if ( document.readyState === 'loading' ) {
				document.addEventListener( "DOMContentLoaded", onLoaded, false );
			} else {
				resolve();
			}
		});
	}
Execute the given callback once the DOM is ready (which might already be the case).

@returns {Promise<void>} Returns a promise that settles after DOM became ready