[wp-hackers] google jquery; wp fall back?

Rafael Ehlers rafaehlers at gmail.com
Mon Nov 29 13:37:18 UTC 2010


I think this solution is better, just put this on in your functions.php:

function current_jquery($version) {
        global $wp_scripts;
        if ( ( version_compare($version, $wp_scripts ->
registered[jquery] -> ver) == 1 ) && !is_admin() ) {
                wp_deregister_script('jquery');

                wp_register_script('jquery',

'http://ajax.googleapis.com/ajax/libs/jquery/'.$version.'/jquery.min.js',
                        false, $version);
        }}

add_action( 'wp_head', current_jquery( '1.4.2' ) ); // change number
to latest version


as seen on: http://bavotasan.com/tutorials/force-wordpress-use-latest-version-jquery/



Rafael *Ehlers*


On Mon, Nov 29, 2010 at 11:33 AM, Barrett Golding <bg at hearingvoices.com>wrote:

> following up on a question i asked here a month ago,
> re: calling Google's CDN copy of jquery but falling back on WP's installed
> copy
> (for the few times -- and countries -- when Google is unavailable.)
>
> solution ended up being:
>
> in header.php:
> wp_enqueue_script( 'jquery' );
>
> in footer.php:
> <script type="application/x-javascript">!window.jQuery &&
> document.write('<script src="<?php echo site_url() .
> "/wp-includes/js/jquery/jquery.js"; ?>"><\/script>')</script>
>
> putting both in head did NOT work, but above method does. more info:
> http://pubmedia.us/2010/11/calling-all-jquerys/
>
> ('course, also requires de-/re-registering 'jquery' in functions.php to get
> Google's copy.)
>
> bg
> --
> <http://HearingVoices.com/>
> ~radio active transmissions~
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list