jQuery UI Accordion loading very slow

Question

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 http://levelupnowyou.com/1591113365325/product/testing-2-womens-racerback-tank/.

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!

0
, bluedimensional 1 year 2020-07-21T14:10:19-05:00 0 Answers 50 views 0

Leave an answer

Browse
Browse