Scripts don’t get printed at the wp_enqueue_scripts
hook, but rather at the wp_print_scripts
hook. That said: don’t echo/print scripts, period. Instead, enqueue them properly.
Caveat: This method is Plugin territory, and should not be included as Theme code in a publicly distributed Theme.
You deregister jQuery, but the step you’re missing is registering and enqueueing your own version:
<?php
function sbi_cdn_jquery() {
// Deregister core-bundled jQuery
// This is dangerous! Understand the
// potential consequences before doing this!
wp_deregister_script( 'jquery' );
// Register custom jQuery version
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' );
// Enqueue cusotm jQuery
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_scripts', 'sbi_cdn_jquery' );
?>
Refer to the Codex entry for wp_register_script()
and wp_enqueue_script()
regarding arguments for these functions.