• in includes/class-galleries.php the admin-gallery.js is being defined like so :
    wp_enqueue_script( 'responsive-lightbox-admin-gallery', RESPONSIVE_LIGHTBOX_URL . '/js/admin-gallery.js', array( 'jquery' ), $rl->defaults['version'], false );

    However it also depends on underscore. In case of other scripts that push e.g. underscore to the footer, the admin-gallery.js fails to load with

    Uncaught ReferenceError: _ is not defined
        at Object.init (admin-gallery.js?ver=2.2.1:15)
        at admin-gallery.js?ver=2.2.1:331
        at admin-gallery.js?ver=2.2.1:333

    This can be fixed by adding the proper dependency into the array like so :
    wp_enqueue_script( 'responsive-lightbox-admin-gallery', RESPONSIVE_LIGHTBOX_URL . '/js/admin-gallery.js', array( 'jquery', 'underscore' ), $rl->defaults['version'], false );

    • This topic was modified 6 years, 6 months ago by disagree.

The topic ‘admin javascript depends on underscore’ is closed to new replies.