Skip to main content
1 of 2

How do you load js and style resources from CDN with local fallback using wp_enqueue_scripts?

I had a hard time finding the correct way to do this. I want to load the CDN resources here: http://www.bootstrapcdn.com/ but use wp_enqueue_scripts and have local fall back.

This is the method I am using for local fall back now directly in header.php: window.jQuery || document.write('\x3C/script>')

I want something like this for all resources but also using wp_enqueue_scripts. I successful switched the enqueue Jquery using this method but this does not provide a fallback: /** Jquery **/ wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js','', 'latest', true ); wp_enqueue_script('jquery','','',true);

Any help is greatly appreciated!