Skip to content

Instantly share code, notes, and snippets.

@RhythmShahriar
Last active February 11, 2017 11:47
Show Gist options
  • Select an option

  • Save RhythmShahriar/858b3af60288be408ef8f7c727873e30 to your computer and use it in GitHub Desktop.

Select an option

Save RhythmShahriar/858b3af60288be408ef8f7c727873e30 to your computer and use it in GitHub Desktop.
/**-------------------------------------------------
* @package Code Snippets
* @link http://rhythmshahriar.com/codes/
* @author Rhythm Shahriar <[email protected]>
* @link http://rhythmshahriar.com
* @copyright Copyright © 2017, Rhythm Shahriar
---------------------------------------------------*/
if( !is_admin()){
$url = 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js';
$test_url = @fopen($url,'r');
if($test_url !== false) {
function load_external_jQuery() {
wp_deregister_script('jquery');
wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js');
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'load_external_jQuery');
} else {
function load_local_jQuery() {
wp_deregister_script('jquery');
wp_register_script('jquery', get_template_directory_uri() . '/assets/js/jquery-1.11.1.min.js', __FILE__, false, '1.11.1', true);
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'load_local_jQuery');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment