wp enqueue script - Uncaught ReferenceError: jQuery is not defined

admin2025-06-04  15

It is a well discussed problem, but I can't find the issue (I've been researching it for days now); Uncaught ReferenceError: jQuery is not defined

jQuery seems not te be loaded within my custom template. So I pass the jQuery argument when enqueuing the script:

// Load scripts in header
function html5blank_header_scripts() {
    wp_register_script('scripts', get_template_directory_uri() . 
'/assets/scripts_head.js', array('jquery'), '1.2', true);
    wp_enqueue_script('scripts');
}

I use jQuery in non-conflicting mode and it is wrapped in document ready function:

jQuery( document ).ready( function( $ ) {
    // case carousel
    jQuery(document).on('ready', function() {
        jQuery('.slider_sector').slick({
            infinite: true,
            speed: 600,
            slidesToShow: 1,
            slidesToScroll: 1,
            accessibility: true,
            centerMode: true,
            lazyLoad: 'ondemand',
            variableWidth: true
        });
    });
});

When including jQuery manually by inserting <script src=".11.2.min.js" type="text/javascript"></script> in the head, the error goes away.

I should not have to load jQuery manually if array('jquery') is passed while loading right?

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1749040904a315855.html

最新回复(0)