• Ultimate FAQs enqueues a large number of JavaScript files (mostly jQuery UI Effects) on every page of a site it’s activated on. I’d love to see two improvements here:

    1. Only enqueue required files. It looks like most of these effects are used in the Premium version of the plugin. Are they required for the free one? In the premium edition, maybe only enqueue the selected reveal effect?
    2. Only enqueue the FAQ-related JS & CSS on pages that contain the plugin’s shortcode.

    The general reduction of HTTP calls, even with HTTP/2, would help with making better performing web pages.

    Thank you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • etoilewebdesign

    (@etoilewebdesign)

    Hi Shawn,

    Thank you for the feature suggestions, they’re much appreciated. We’ll take a look at these to see if we can reduce the number of calls and/or make them only when necessary.

    If you know how to modify your own Theme code, you could for now add something like this to your ‘functions.php’ under your theme:

    function dequeue_conditional_styles(){
        if( (!strpos($_SERVER["REQUEST_URI"], 'faqs')) ) {
          $removeFAQScript = false;
          if (function_exists( 'is_woocommerce' )) {
             if (!is_woocommerce()) {
                $removeFAQScript = true;
             }
          } else {
             $removeFAQScript = true;
          }
          if ($removeFAQScript) {
             wp_dequeue_style('ewd-ufaq-style');
             wp_dequeue_style('ewd-ufaq-rrssb');
             wp_dequeue_script('ewd-ufaq-js');
             wp_dequeue_script('jquery-ui-core');
          }
          wp_dequeue_script('jquery-effects-core');
          wp_dequeue_script('jquery-ui-autocomplete');
          wp_dequeue_script('jquery-effects-blind');
          wp_dequeue_script('jquery-effects-bounce');
          wp_dequeue_script('jquery-effects-clip');
          wp_dequeue_script('jquery-effects-drop');
          wp_dequeue_script('jquery-effects-explode');
          wp_dequeue_script('jquery-effects-fade');
          wp_dequeue_script('jquery-effects-fold');
          wp_dequeue_script('jquery-effects-highlight');
          wp_dequeue_script('jquery-effects-pulsate');
          wp_dequeue_script('jquery-effects-scale');
          wp_dequeue_script('jquery-effects-shake');
          wp_dequeue_script('jquery-effects-slide');
          wp_dequeue_script('jquery-effects-transfer');
        }
    }
    add_action( 'wp_enqueue_scripts', 'dequeue_conditional_styles', 20 );

    This is basically checking the pages URL doesn’t have ‘faqs’ in it (adjust if your base FAQ URL slug is named something else).

    It also checks if the Woocommerce plugin is available, and if so ensures not to remove the main scripts from the Woocommerce products pages (incase you have Ultimate FAQs on them too). The effects are still removed, but you can adjust to your desire. Any issues, tweak or remove it. It’s just a temporary patch for now, but should do the trick.

    If you require those scripts such as jQuery UI Core or Effects for other webpage/plugin uses, don’t remove them.

    • This reply was modified 7 years, 12 months ago by 3Lancer.
    • This reply was modified 7 years, 12 months ago by 3Lancer.
    Thread Starter Shawn Hooper

    (@shooper)

    Thanks @3lancer !

    That’ll do the trick for now.

    Cheers.
    Shawn

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Large Number of HTTP Calls for jQuery UI Effects’ is closed to new replies.