• Resolved Generosus

    (@generosus)


    Good Day,

    We are using Speed Optimizer to combine all of our JS files and the deferral of all render-blocking files, including jQuery. It’s working great. However, we need filters to exclude the combination and deferral of jQuery on one of our pages (say, “custom-login-page“). What filters can we use?

    For example, the following filters are not working for us:

    add_action( 'wp_footer', function () {
    
    if ( ! is_page('custom-login-page') ) return;
    
    add_filter( 'sgo_javascript_combine_exclude', 'js_combine_exclude_login' ); 
    function js_combine_exclude_login( $exclude_list ) { 
    
    $exclude_list[] = 'jquery-core'; 
    
    return $exclude_list; }
    
    } );
    add_action( 'wp_footer', function () {
    
    if ( ! is_page('custom-login-page') ) return;
    
    add_filter( 'sgo_js_async_exclude', 'js_async_exclude_login' ); 
    function js_async_exclude_login( $exclude_list ) {
    
    $exclude_list[] = 'jquery-core';
    
    return $exclude_list;
    }
    
    } );

    Note: Our page, “custom-login-page“, is our mask for our “wp-admin” login page.

    Thank you.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Plamen M

    (@plamenm)

    Hello @generosus,

    Please make sure you’re using the correct type of filter – there’s the standard one, the filter for external scripts or the filter for inline scripts. We have examples for these scenarios here:

    https://eu.siteground.com/tutorials/wordpress/speed-optimizer/custom-filters/

    Also, the correct script handle should be used in the filter. Depending on how the jQuery is added to your site’s code, these two would differ.

    If you’re still unable to exclude the script, please?post a support ticket through the SiteGround’s Help Desk area and we will gladly try to assist you further.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Thread Starter Generosus

    (@generosus)

    Hi @plamenm,

    Thanks for the info. Yes, aware of all of it. We confirmed the data-handle for our jQuery file is “jquery-core

    So, based on your information, can you kindly review the above code snippets for validity and/or provide the ones that work using your filters?

    Also, we tried to open a support ticket first, but was referred to this forum for a solution. Check our chat records.

    Thank you.

    PS: Please do not close this topic as “Resolved” until it’s actually resolved.

    Plugin Support Plamen M

    (@plamenm)

    I apologize for the support loop that happened here. A support request through our internal support channels would allow us to check your actual site and plugin setup instead of supposing what might work. This is why, since your site is hosted with us, it is best to always post your support requests through the Helpdesk Center in your User Area. Additionally, in a public forum we are restricted to ask for and provide specific details, due to privacy reasons.

    In the current case, our plugin developers believe that the filters do not work, because you are trying to exclude a script from the footer of the page. The site hook which loads the footer elements is called way to late in the DOM process. Our plugin is looking to exclude the scripts in the init process instead. For the filters to function properly, the script inclusion should occur at an earlier stage of the page loading process. You may try to move the script into the wp_print_scripts hook’s stage instead.

    Additionally, please note that marking a thread here as “resolved” is only a status, and does not in any way prevent you from re-opening the thread with additional details or continuing the discussion.

    Regards,
    Plamen.M
    Tech Support Team
    SiteGround.com

    Thread Starter Generosus

    (@generosus)

    Thank you, Plamen. We’ll re-submit a support ticket for detailed assistance. Hopefully, they won’t send us back to this forum. Cheers.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Filters to Exclude JS Combination and Deferral (Per Page Basis)’ is closed to new replies.