Conditional Script Loading for Shotcode

In the functions.php file or in your plugin file write the code below โ€“

[php]

/**
* Check if it should load frontend scripts
*
* @return mixed|void
*/
private function should_load_scripts() {
global $post;
$load_scripts = is_active_widget( false, false, ‘wpl_logo_carousel_pro_widget_content’, true ) || ( is_a( $post, ‘WP_Post’ ) && has_shortcode( $post->post_content, ‘logo-carousel-pro’ ) );

return apply_filters( ‘logo_carousel_pro_load_scripts’, $load_scripts );
}

/**
* Plugin Scripts and Styles
*
*/
function public_scripts() {
if ( $this->should_load_scripts() ) {
wp_enqueue_script( ‘jquery-isotope-min-js’, MY_URL . ‘assets/js/jquery.isotope.min.js’, array( ‘jquery’ ), $this->version, false );
}
}

[/php]