# wp-parsely/3.3.2/src/js/lib/loader.js

Parse.ly, version 3.3.2. 59 lines.

- Page: https://pluginprobe.com/plugins/wp-parsely/3.3.2/code/src/js/lib/loader.js
- Raw: https://pluginprobe.com/plugins/wp-parsely/3.3.2/raw/src/js/lib/loader.js
- Modified: 2022-05-02T10:45:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-parsely/3.3.2/code/src/js/lib/loader.js#L10-L20`.

```javascript
import { createHooks } from '@wordpress/hooks';

window.wpParselyHooks = createHooks();

export function wpParselyInitCustom() {
	/**
	 * The `wpParselyOnLoad` hook gets called with the `onload` event of the `window.PARSELY` object.
	 * All functions enqueued on that hook will be executed on that event according to their priorities. Those
	 * functions should not expect any parameters and shouldn't return any.
	 */
	const customOnLoad = () => window.wpParselyHooks.doAction( 'wpParselyOnLoad' );

	/**
	 * The `wpParselyOnReady` hook gets called with the `onReady` event of the `window.PARSELY` object.
	 * All functions enqueued on that hook will be executed on that event according to their priorities. Those
	 * functions should not expect any parameters and shouldn't return any.
	 */
	const customOnReady = () => window.wpParselyHooks.doAction( 'wpParselyOnReady' );

	// Construct window.PARSELY object.
	if ( typeof window.PARSELY === 'object' ) {
		if ( typeof window.PARSELY.onload !== 'function' ) {
			window.PARSELY.onload = customOnLoad;
		} else {
			const oldOnLoad = window.PARSELY.onload;
			window.PARSELY.onload = function() {
				if ( oldOnLoad ) {
					oldOnLoad();
				}
				customOnLoad();
			};
		}

		if ( typeof window.PARSELY.onReady !== 'function' ) {
			window.PARSELY.onReady = customOnReady;
		} else {
			const oldOnReady = window.PARSELY.onReady;
			window.PARSELY.onReady = function() {
				if ( oldOnReady ) {
					oldOnReady();
				}
				customOnReady();
			};
		}
	} else {
		window.PARSELY = {
			onload: customOnLoad,
			onReady: customOnReady,
		};
	}

	// Disable autotrack if it was set as such in settings.
	if ( window.wpParselyDisableAutotrack === true ) {
		window.PARSELY.autotrack = false;
	}
}

wpParselyInitCustom();

```
