wp_prototype_before_jquery()WP 2.3.1

Reorders JavaScript scripts array to place prototype before jQuery.

No Hooks.

Return

String[]. Reordered array, if needed.

Usage

wp_prototype_before_jquery( $js_array );
$js_array(string[]) (required)
JavaScript scripts array

Changelog

Since 2.3.1 Introduced.

wp_prototype_before_jquery() code WP 6.5.2

function wp_prototype_before_jquery( $js_array ) {
	$prototype = array_search( 'prototype', $js_array, true );

	if ( false === $prototype ) {
		return $js_array;
	}

	$jquery = array_search( 'jquery', $js_array, true );

	if ( false === $jquery ) {
		return $js_array;
	}

	if ( $prototype < $jquery ) {
		return $js_array;
	}

	unset( $js_array[ $prototype ] );

	array_splice( $js_array, $jquery, 0, 'prototype' );

	return $js_array;
}