/ Published in: PHP

This code should be added to the functions.php file in the theme's folder. The code will deregister the local copy of jQuery and instead include the google hosted copy. It will also register other scripts.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php function my_script_init() { if (!is_admin()) { // deregister local copy of jQuery wp_deregister_script('jquery'); // register google hosted jquery wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js', false, '1.6.1'); wp_enqueue_script('jquery'); // register some other javascript file (just for the sake example) wp_register_script('otherfile', get_bloginfo('stylesheet_directory').'/scripts/jquery.otherFile.js', array('jquery')); wp_enqueue_script('otherfile'); // register another file that requires that the other two files are loaded first wp_register_script('mainjs', get_bloginfo('stylesheet_directory').'/scripts/main.js', array('jquery','otherfile')); wp_enqueue_script('mainjs'); wp_deregister_script( 'l10n' ); } } add_action('init', 'my_script_init');
Comments
