• Resolved igarciaoliver

    (@igarciaoliver)


    hi everyone
    I am having an issue with the Siteground optimizer plugin and deferred scripts.
    I am using ACF pro to create a Gutenberg block with enqueue_assets and referencing another script as a dependency.

    // dependency
    wp_enqueue_script( ‘theme-utils’, get_template_directory_uri() . ‘/js/utils.js’, array(), _S_VERSION, true );
    // ACF Block
    acf_register_block_type( array(
    ……
    ‘enqueue_assets’ => function(){
    wp_enqueue_script( ‘accordion-script’, get_template_directory_uri() .’/template-parts/blocks/accordion/accordion-block.js’, [‘jquery’, ‘theme-utils’], ‘2.2’, true );
    },
    }
    thing is it’s not respecting the dependency and accordion-script is loaded before theme-utils.

    If I remove theme-utils from the deferred list (or disable to plugin), it works.

    I also cannot see the ACF block script listed on the options to remove it from defered so I think the SG plugin is not registering it at all.
    is this a know bug?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Simeon Boev

    (@k3llanved)

    Hello @igarciaoliver,

    Depending on how the scripts or styles are included by plugin/themes we may not detect them, thus they are not listed. Nevertheless, you could still exclude any script using a filter:

    add_filter( 'sgo_js_async_exclude', 'js_async_exclude' );
    function js_async_exclude( $exclude_list ) {
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    The only thing here that you require is the handler used by the plugin.

    Best Regards,
    Simeon Boev

    Thread Starter igarciaoliver

    (@igarciaoliver)

    Hi @k3llanved

    I know about the filter, thanks. I was raising the issue in case it was a fixable bug that your team could look into ??

    I fixed my site adding a defer to my block script.

    Plugin Support Simeon Boev

    (@k3llanved)

    I will leave a note to our developers so they can check the case as soon as possible. In the meantime, I will leave the topic open.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Defered Scripts and ACF Pro Gutenberg Blocks’ is closed to new replies.