Title: Combine Javascript Files (Cannot Exclude JS FIle)
Last modified: April 28, 2020

---

# Combine Javascript Files (Cannot Exclude JS FIle)

 *  Resolved [jetxpert](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/)
 * 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](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [6 years, 1 month ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-12746789)
 * 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](https://wordpress.org/support/users/jetxpert/).
 *  Plugin Author [Stanimir Stoyanov](https://wordpress.org/support/users/sstoqnov/)
 * (@sstoqnov)
 * SiteGround Representative
 * [6 years ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-12757722)
 * Hey [@jetxpert](https://wordpress.org/support/users/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.wordpress.org/reference/functions/wp_enqueue_script/](https://developer.wordpress.org/reference/functions/wp_enqueue_script/)
 * Regards,
    Stanimir
 *  Thread Starter [jetxpert](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [6 years ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-12758219)
 * [@sstoqnov](https://wordpress.org/support/users/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](https://www.siteground.com/tutorials/wordpress/sg-optimizer/).
 * Again, thank you. Please stay safe!
 *  [wpkum](https://wordpress.org/support/users/wpkum/)
 * (@wpkum)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13168966)
 * [@jetxpert](https://wordpress.org/support/users/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](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13169061)
 * [@wpkum](https://wordpress.org/support/users/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.
 *  [wpkum](https://wordpress.org/support/users/wpkum/)
 * (@wpkum)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13171728)
 * [@jetxpert](https://wordpress.org/support/users/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](https://wordpress.org/support/users/jetxpert/)
 * (@jetxpert)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13172735)
 * [@wpkum](https://wordpress.org/support/users/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](http://prntscr.com/tox43y)
    [ENVIRONMENT OPTIMIZATION](http://prntscr.com/tox5uk)
   [FRONTEND OPTIMIZATION](http://prntscr.com/tox64g) [MEDIA OPTIMIZATION](http://prntscr.com/tox6kc)
 * **WP Rocket Settings:**
 * We followed the instructions provided [here](https://onlinemediamasters.com/wp-rocket-settings/),
   [here](https://docs.wp-rocket.me/article/115-can-i-use-wp-rocket-with-sg-optimizer),
   and [here](https://wordpress.org/support/topic/wp-rocket-sg-optimizer-best-practices/).
 * **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](https://wordpress.org/support/users/hristo-sg/)
 * (@hristo-sg)
 * SiteGround Representative
 * [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13173450)
 * 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.

 * ![](https://ps.w.org/sg-cachepress/assets/icon-256x256.gif?rev=2971889)
 * [Speed Optimizer - The All-In-One Performance-Boosting Plugin](https://wordpress.org/plugins/sg-cachepress/)
 * [Support Threads](https://wordpress.org/support/plugin/sg-cachepress/)
 * [Active Topics](https://wordpress.org/support/plugin/sg-cachepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sg-cachepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sg-cachepress/reviews/)

 * 8 replies
 * 4 participants
 * Last reply from: [Hristo Pandjarov](https://wordpress.org/support/users/hristo-sg/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/combine-javascript-files-cannot-exclude-js-file/#post-13173450)
 * Status: resolved