TransWikia.com

jQuery UI Accordion loading very slow

WordPress Development Asked by bluedimensional on November 11, 2021

I have a jQuery UI Accordion implemented and as the page loads, you see content of the three headers and tabs for a few seconds, and then they turn into the accordion. I’m not sure which part is causing the delay, and hoping you can help.

In my functions.php:

// Enqueue jQuery accordion
function product_accordion()
{
    if ((is_product()) || (is_archive())){

        wp_enqueue_style('jquery-ui', get_stylesheet_directory_uri() . '/css/jquery-ui.css', 10);
        
        wp_register_script('jquery-core', get_stylesheet_directory_uri() . 'https://code.jquery.com/jquery-1.8.2.js', array('jquery'), '1.0', true);
        wp_enqueue_script('jquery-core');
        
        wp_register_script('jquery-ui', 'https://code.jquery.com/ui/1.9.0/jquery-ui.js', array('jquery'), '1.0', true);
        wp_enqueue_script('jquery-ui');
        
        wp_register_script('accordion-snippet', get_stylesheet_directory_uri() . '/js/accordion-snippet.js', array('jquery'), '1.0', true);
        wp_enqueue_script('accordion-snippet');
        
    }
}
add_action('wp_enqueue_scripts', 'product_accordion');

The accordion-snippet.js enqueued above:

      jQuery('#accordion').accordion({ 
            collapsible:true, 
            active:false, 
            autoHeight: false, 
            disabled:true,
            heightStyle: "content"
      });

      jQuery('#accordion h3.ui-accordion-header').click(function(){
            jQuery(this).next().slideToggle();
      });
      
      jQuery('.accordion-expand-all').click(function(){
            jQuery('#accordion h3.ui-accordion-header').next().slideDown();
      });
      console.log("accordion-snippet.js loaded");

and you can see it here.

What is causing the delay in the Accordion being loaded? And / or any tips on troubleshooting this would be great too.
Please let me know if I need to provide anything else.Thanks!

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP