HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/advanced-ads/public/assets/js/ready.js
/**
 * Wait for the page to be ready before firing JS.
 *
 * @param {function} callback - A callable function to be executed.
 * @param {string} [requestedState=complete] - document.readyState to wait for. Defaults to 'complete', can be 'interactive'.
 */
window.advanced_ads_ready = function ( callback, requestedState ) {
	requestedState = requestedState || 'complete';
	var checkState = function ( state ) {
		return requestedState === 'interactive' ? state !== 'loading' : state === 'complete';
	};

	// If we have reached the correct state, fire the callback.
	if ( checkState( document.readyState ) ) {
		callback();
		return;
	}
	// We are not yet in the correct state, attach an event handler, only fire once if the requested state is 'interactive'.
	document.addEventListener( 'readystatechange', function ( event ) {
		if ( checkState( event.target.readyState ) ) {
			callback();
		}
	}, {once: requestedState === 'interactive'} );
};

window.advanced_ads_ready_queue = window.advanced_ads_ready_queue || [];