How to use the @automattic/load-script.loadjQueryDependentScript function in @automattic/load-script

To help you get started, we’ve selected a few @automattic/load-script examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Automattic / wp-calypso / client / lib / load-jquery-dependent-script-desktop-wrapper / index.js View on Github external
export function loadjQueryDependentScriptDesktopWrapper( url, callback ) {
	debug( `Loading a jQuery dependent script from "${ url }"` );

	// It is not possible to expose jQuery globally in Electron App: https://github.com/atom/electron/issues/254.
	// It needs to be loaded using require and npm package.
	if ( config.isEnabled( 'desktop' ) ) {
		debug( `Attaching jQuery from node_modules to window for "${ url }"` );
		asyncRequire( 'jquery', $ => {
			window.$ = window.jQuery = $;
			loadScript( url, callback );
		} );
		return;
	}

	loadjQueryDependentScript( url, callback );
}

@automattic/load-script

Async Script Loader.

GPL-2.0
Latest version published 5 years ago

Package Health Score

73 / 100
Full package analysis