/**
 * @license Copyright (c) 2017-2025, CKSource Holding sp. z o.o. All rights reserved.
 * For licensing, see LICENSE.md.
 */

export function afterDomReady( callback ) {
	if ( document.readyState === 'loading' ) {
		return new Promise( resolve => {
			document.addEventListener( 'DOMContentLoaded', () => {
				resolve( callback() );
			} );
		} );
	}

	return callback();
}
