removing unnecessary code?

Your Account / Forums / Easy FancyBox Pro / removing unnecessary code?

  • Author
    • Anonymous
      May 8, 2014 at 10:44 pm #3383


      I just purchased Easy FancyBox Pro, and it is working well. I noticed that the plugin is loading a bunch of js and css code on every page of my site:

      <!-- Easy FancyBox 1.5.6 using FancyBox 1.3.6 - RavanH ( -->
      <script type="text/javascript">
      /* <![CDATA[ */
      var fb_timeout = null;

      Is there an easy way to only include this code on pages where the fancybox plugin is being used? I am only using FancyBox features on one page.


    • May 8, 2014 at 10:44 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);
  • You must be logged in to reply to this topic.