Custom Fields
Re-Envisioned
Support MB Blocks Blocks enqueue_assets is loaded everywhere

  • Creator
    Topic
  • #16118
    Resolved SG
    Participant

    I have created a custom block which uses

    'enqueue_assets' => function() {
                    wp_enqueue_style( 'glidecss', get_template_directory_uri() . '/blocks/sliderglide/css/glide.min.css', [], '1.0' );
                    wp_enqueue_script( 'glidejs', get_template_directory_uri() . '/blocks/sliderglide/js/glide.min.js', ['jquery'], '1.0', true );
                    wp_enqueue_script( 'glide-launcher', get_template_directory_uri() . '/blocks/sliderglide/js/glide-launcher.js', ['glidejs'], '', true );
                },

    Now the problem is that this is loaded everywhere in the admin area which will results in an error because something is missing: TypeError: this.root is undefined glide.min.js:6:7415

    How can I the resources only on gutenberg enabled admin pages?

    The error prevents other JS to execute properly, for example The Meta Box Builder.

Viewing 1 replies (of 1 total)
  • Author
    Replies
  • #16129
    Anh Tran
    Keymaster

    Thanks for your feedback. I’ve just fixed it in version 1.0.7. Please update.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.