Reply To: removing unnecessary code?

Your Account / Forums / Easy FancyBox Pro / removing unnecessary code? / Reply To: removing unnecessary code?

May 9, 2014 at 7:16 pm #3384

Hi Devin,

The plugin itself can not detect if the code is going to be needed or not so that is why it is included in every page. That said, you can manually add the following code to your themes functions.php file. I’m supposing here that the page in question has slug ‘portfolio’ used in !is_page('portfolio') but you can change that to fit your case 🙂


function my_conditional_script() {
  if( class_exists('easyFancyBox') && !is_page('portfolio') ) {
    remove_action('wp_enqueue_scripts', array('easyFancyBox','enqueue_styles'), 999);
    remove_action('wp_print_scripts', array('easyFancyBox','register_scripts'), 999);
    remove_action('wp_head', array('easyFancyBox','main_script', 999);
    remove_action('wp_footer', array('easyFancyBox','enqueue_footer_scripts'), 999);
    remove_action('wp_footer', array('easyFancyBox', 'on_ready'), 999);
  }
}
add_action('wp_head','my_conditional_scripts',0);