$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>wp enqueue script - Uncaught ReferenceError: jQuery is not defined|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

wp enqueue script - Uncaught ReferenceError: jQuery is not defined

matteradmin8PV0评论

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?

Post a comment

comment list (0)

  1. No comments so far