Add page specific javascript from plugin

//add jquery plugins for specific page
add_action( "template_redirect", "check_to_enqueue_scripts" ) );

//function to check if propose-trade page then enqueue scripts
function check_to_enqueue_scripts(){
if( is_page( 338 ) ){
add_action('wp_enqueue_scripts', "enqueue_plugin_scripts" );
}
}
//function to enqueue my page specific scripts
function enqueue_plugin_scripts(){
wp_enqueue_script('my-page-specific-script');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');

}

1 Comment

You must be logged in to post a comment.


  1. The action trick has gotten me out of so many jams.