Created
September 14, 2013 15:22
-
-
Save ZellSnippets/6562890 to your computer and use it in GitHub Desktop.
WP: Enqueue Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Load scripts | |
* | |
* Only load these scripts on the front-end. | |
* | |
* @since 2.0.0 | |
*/ | |
add_action( 'wp_enqueue_scripts', 'zell_scripts' ); | |
function zell_scripts() { | |
// Registering script | |
// ['name','src','dependencies','version','in_footer'] | |
// | |
if( !is_admin() ) { | |
// Override WP'd default self-hosted jQuery with version from Google's CDN | |
wp_deregister_script( 'jquery' ); | |
wp_register_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', array(), null, true ); | |
wp_register_script ( 'scrollTo', get_stylesheet_directory_uri() . '/js/vendor/jquery.scrollTo-1.4.3.1-min.js', array( 'jquery' ), null, true ); | |
wp_register_script ( 'localscroll', get_stylesheet_directory_uri() . '/js/vendor/jquery.localscroll-1.2.7-min.js', array( 'scrollTo' ), null, true ); | |
wp_register_script ( 'modernizr', get_stylesheet_directory_uri() . '/js/vendor/modernizr.js', array( 'jquery' ), null, true ); | |
wp_register_script ( 'scroll-spy', get_stylesheet_directory_uri() . '/js/vendor/jquery-scrollspy.js', array( 'jquery'), null, true); | |
wp_register_script ( 'highlight-js', get_stylesheet_directory_uri() . '/js/vendor/highlight.js/highlight.pack.js', null, true); | |
// Main script file (in footer) | |
wp_enqueue_script( 'localscroll' ); | |
wp_enqueue_script( 'modernizr'); | |
wp_enqueue_script( 'scroll-spy' ); | |
wp_enqueue_script( 'highlight-js' ); | |
wp_enqueue_script( 'wk-js', get_stylesheet_directory_uri() . '/js/scripts.js', array( 'jquery' ), null, true ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment