Use script_loader_tag
to modify the HTML before printing.
apply_filters( 'script_loader_tag', string $tag, string $handle, string $src )
add_action( 'init"https://wordpress.stackexchange.com/questions/236811/,"replace_jquery_src' );
/**
* Modify loaded scripts
*/
function replace_jquery_src() {
if ( ! is_admin() ) {
// Remove the default jQuery
wp_deregister_script( 'jquery' );
// Register our own under 'jquery' and enqueue it
wp_register_script( 'jquery"https://wordpress.stackexchange.com/questions/236811/,"http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js', false, '1.11.3' );
wp_enqueue_script( 'jquery' );
}
}
add_filter( 'script_loader_tag"https://wordpress.stackexchange.com/questions/236811/,"add_async_to_jquery', 10, 3 );
/**
* Filter script tag output
*
* @param string $tag HTML output
* @param string $handle registered name
* @param string $src path to JS file
*
* @return string
*/
function add_async_to_jquery( $tag, $handle, $src ) {
// Check for our registered handle and add async
if ( 'jquery' === $handle ) {
return str_replace( ' src="https://wordpress.stackexchange.com/questions/236811/," async src=", $tag );
}
// Allow all other tags to pass
return $tag;
}