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.
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
@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.
@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,
@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!
I do not recommend using WP Rocket with the SG Optimizer at all.