• Resolved jetxpert

    (@jetxpert)


    We are testing SG Optimizer 5.5.0. When we activate “Combine Javascript Files” the drop-down menu for excluding certain JS files does not list the one we need to exclude.

    We are limited to the JS files that SG Optimizer selects or detects. Other plugins (e.g., WP Rocket) allow us to manually enter the JS file we wish to exclude. The same goes for “Combine CSS Files.”

    Kindly advise how can we enter a custom JS or CSS file into the exclusion list.

    Thank you!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter jetxpert

    (@jetxpert)

    One more thing …

    On the home page of the SG Optimizer plugin we found several exclusion filters. Unfortunately, we did not find an exclusion filter for “Combine Javascript Files.” We extrapolated from other filters given and came up with the following:

    add_filter( 'sgo_js_combine_exclude', 'js_combine_exclude' );
    function js_combine_exclude( $exclude_list ) {
        // Add the style handle to exclude list.
        $exclude_list[] = 'script-handle';
        $exclude_list[] = 'script-handle-2';
    
        return $exclude_list;
    }

    We replaced ‘script-handle’ and ‘script-handle-2’ with the file path (js file) that needs to be excluded from the “Combine Javascript Files” option in the plugin but it did not work at all.

    Can you explain better how to use filters provided in the plugin’s home page? Also, please define ‘script-handle’ or ‘style-handle’ No definition found anywhere.

    Thank you!

    • This reply was modified 6 years, 1 month ago by jetxpert.
    Plugin Author Stanimir Stoyanov

    (@sstoqnov)

    SiteGround Representative

    Hey @jetxpert

    We’ve updated the plugin readme, so you can refer to the javascript hooks.

    The script handle is the unique name of the script upon script registration.

    You can read more about the handle here:
    https://developer.ww.wp.xz.cn/reference/functions/wp_enqueue_script/

    Regards,
    Stanimir

    Thread Starter jetxpert

    (@jetxpert)

    @sstoqnov,

    Thank you!

    Your new Combine Javascript File exclusion filter adds a new $exclude_list[] parameter called “script-host.com” Is this the JS file path? If we exclude the “host.com” aren’t we also excluding non-offending JS files that can be combined?

    Also, can you update the plugin readme file to include a definition of the $exclude_list[] parameters noted in your filters? An example of how to use them would be great as well.

    Last, would be great if SG can add the above info to your SG Optimizer Tutorial.

    Again, thank you. Please stay safe!

    @jetxpert Is this issue solved for you? I want to exclude a few JS and CSS files manually. Your help will be appreciated.

    Thread Starter jetxpert

    (@jetxpert)

    @wpkum,

    Yes. Please refer to the first topic (procedure) pinned at the top of this support forum.

    Alternatively, you can disable SG Optimizer’s “Combine JS Files” and “Combine CSS Files” features and use WP Rocket’s equivalent functionalities instead. WP Rocket allows you exclude files using the affected file path without the need to create a separate PHP filter.

    And in case you’re wondering, you will get the best of both worlds when using both SG Optimizer and WP Rocket simultaneously.

    Best wishes. Please stay safe.

    @jetxpert First, I would like to thank for your reply. I have purchased WP Rocket now. Can you recommend what’s the best settings (as fast as) to work with SG Optimizer?

    What options should be disabled on SG Optimizer?

    Regards,

    Thread Starter jetxpert

    (@jetxpert)

    @wpkum,

    As you know, each website responds differently to plugin settings. With that in mind, below is what we’re using for our website.

    SG Settings:

    SUPERCACHER SETTINGS
    ENVIRONMENT OPTIMIZATION
    FRONTEND OPTIMIZATION
    MEDIA OPTIMIZATION

    WP Rocket Settings:

    We followed the instructions provided here, here, and here.

    Notes:

    (1) We do not use SG Optimizer nor WP Rocket to lazyload our images. We use our theme’s built in feature instead (it’s more efficient).

    (2) Common features that have been turned on in SG Optimizer, have been turned off in WP Rocket.

    Hope the above helps. Best wishes!

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    I do not recommend using WP Rocket with the SG Optimizer at all.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Combine Javascript Files (Cannot Exclude JS FIle)’ is closed to new replies.