Return to Snippet

Revision: 62478
at February 26, 2013 11:44 by ihatetomatoes


Initial Code
/**
 * Additional JS - Scrollorama and header animation only on homepage
 *
 * @since 1.0.0
 *
 */
function scripts() {
	wp_enqueue_script( 'jquery' );
	
	wp_register_script( 'enquire', get_stylesheet_directory_uri().'/assets/js/enquire.min.js');
	wp_enqueue_script( 'enquire' );
	wp_register_script( 'greensock', get_stylesheet_directory_uri().'/assets/js/libs/greensock/TweenMax.min.js');
	wp_enqueue_script( 'greensock' );
	wp_register_script( 'scrollorama', get_stylesheet_directory_uri().'/assets/js/jquery.superscrollorama.js');
	wp_enqueue_script( 'scrollorama' );
	wp_register_script( 'headerAnimation', get_stylesheet_directory_uri().'/assets/js/_header-animation.js');
	wp_enqueue_script( 'headerAnimation' );
	
	if ( !is_front_page() ) {
		wp_deregister_script('scrollorama');
		wp_deregister_script('headerAnimation');
	}
}
wp_enqueue_script( 'base' );
	
add_action( 'wp_print_scripts', 'scripts'); // now just run the function

Initial URL
http://www.position-relative.com/2010/wordpress/wordpress-only-load-plugins-on-pages-that-need-them/

Initial Description
Load scripts only on pages which needs them.

Initial Title
WP - Load script only on some pages

Initial Tags

                                

Initial Language
PHP