• Resolved steveoffsey

    (@steveoffsey)


    When I use the combine javascript option in SG Optimizer I get errors on this page: https://www.pointillist.com/blog/

    I added the following to functions.php to exclude these 3 Essential Grid plugin files, but it looks like they are still being combined by SG Optimizer. What am I doing wrong?

    add_filter( ‘sgo_css_combine_exclude’, ‘css_combine_exclude’ );
    function css_combine_exclude( $exclude_list ) {
    // Add the style handle to exclude list.
    $exclude_list[] = ‘tp-tools’;
    $exclude_list[] = ‘essential-grid-essential-grid-script-js-extra’;
    $exclude_list[] = ‘essential-grid-essential-grid-script’;
    return $exclude_list;
    }

    add_filter( ‘sgo_js_async_exclude’, ‘js_async_exclude’ );
    function js_async_exclude( $exclude_list ) {
    $exclude_list[] = ‘tp-tools’;
    $exclude_list[] = ‘essential-grid-essential-grid-script-js-extra’;
    $exclude_list[] = ‘essential-grid-essential-grid-script’;
    return $exclude_list;
    }

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hey there @steveoffsey,

    If you wish to exclude a script from the JS Combination you can try the dropdown menu under the Combine JavaScript Files. If the scripts are not available you have to use this filter:

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

    The first one you added is for excluding from the CSS combination, and the second one is for excluding scripts from async loading. If you wish to exclude a script from the JS Combination, please use the one above.

    Kind regards,
    Stoyan

    Thread Starter steveoffsey

    (@steveoffsey)

    I added the javascript combine exclude as well as excluded jquery and jquery-migrate from javascript combine and from async, but I’m still getting an error in the esg.min.js only when I turn the javascript combine on (despite all these exclusions). Can you look at https://www.pointillist.com/blog/ and let me know which other javascript files I should exclude from javascript combine and/or async?

    Thanks!

    Plugin Author Stoyan Georgiev

    (@stoyangeorgiev)

    Hello there @steveoffsey,

    There is no need to exclude the jquery and jquery-migrate from the javascript combination.

    I would also suggest checking if you are loading scripts from external sources you can exclude them from the combination using the following code snippet

    add_filter( 'sgo_javascript_combine_excluded_external_paths', 'js_combine_exclude_external_script' );
    function js_combine_exclude_external_script( $exclude_list ) {
        $exclude_list[] = 'script-host.com';
        $exclude_list[] = 'script-host-2.com';
    
        return $exclude_list;
    }

    Also, check for duplicating functionality, make sure you are not using other js combinations like from your theme settings or third-parties like Cloudflare or others.

    Kind regards,
    Stoyan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t get exclude js working’ is closed to new replies.