Title: Fail to unload certain hardcoded scripts
Last modified: December 14, 2020

---

# Fail to unload certain hardcoded scripts

 *  [Rookie](https://wordpress.org/support/users/alriksson/)
 * (@alriksson)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/fail-to-unload-certain-hardcoded-scripts/)
 *     ```
       <script type="text/javascript">jQuery(document).ready(function(){let event=new Event('oxygenVSBInitToggleJs');document.dispatchEvent(event)});document.addEventListener("oxygenVSBInitToggleJs",function(){oxygenVSBInitToggleState()},!1);oxygenVSBInitToggleState=function(){jQuery('.oxy-toggle').each(function(){var initial_state=jQuery(this).attr('data-oxy-toggle-initial-state'),toggle_target=jQuery(this).attr('data-oxy-toggle-target'),active_class=jQuery(this).attr('data-oxy-toggle-active-class');if(initial_state=='closed'){if(!toggle_target){jQuery(this).next().hide()}else{jQuery(toggle_target).hide()}
       jQuery(this).children('.oxy-expand-collapse-icon').addClass('oxy-eci-collapsed');jQuery(this).removeClass(active_class)}else{jQuery(this).addClass(active_class)}})}
       jQuery("body").on('click','.oxy-toggle',function(){var toggle_target=jQuery(this).attr('data-oxy-toggle-target'),active_class=jQuery(this).attr('data-oxy-toggle-active-class');jQuery(this).toggleClass(active_class)
       jQuery(this).children('.oxy-expand-collapse-icon').toggleClass('oxy-eci-collapsed');if(!toggle_target){jQuery(this).next().toggle()}else{jQuery(toggle_target).toggle()}
       jQuery(window).trigger('resize')})</script>
       ```
   
 * Above script from oxygen page builder is still loaded even if unloaded site-wide
   from WPACU. [@gabelivan](https://wordpress.org/support/users/gabelivan/) Could
   you please look into it?
    -  This topic was modified 5 years, 5 months ago by [Rookie](https://wordpress.org/support/users/alriksson/).

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

 *  Plugin Author [Gabe Livan](https://wordpress.org/support/users/gabelivan/)
 * (@gabelivan)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/fail-to-unload-certain-hardcoded-scripts/#post-13796933)
 * [@alriksson](https://wordpress.org/support/users/alriksson/) does it show as 
   unloaded in the hardcoded list? This is important to understand if the rule is
   saved properly. In some cases, when the hardcoded asset contains specific strings
   that change on every page load (e.g. timestamps or security nonces) and in this
   instance, the unloading won’t work since the saved hardcoded asset (marked for
   unloading) is different (even by one character) then the most recent loaded one.
   I’m thinking of a solution for this such as unloading hardcoded scripts based
   on specific patterns.
 * I’ve checked the code you provided and it doesn’t seem to have bits that change
   on every page load. So, it could be a bug. Let me know if it’s saving or not 
   after you mark it as unloaded.
 *  Thread Starter [Rookie](https://wordpress.org/support/users/alriksson/)
 * (@alriksson)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/fail-to-unload-certain-hardcoded-scripts/#post-13797036)
 * > does it show as unloaded in the hardcoded list?
 * [@gabelivan](https://wordpress.org/support/users/gabelivan/) Yes it’s a part 
   of a bigger one. This is the full script in a read-friendly layout:
 *     ```
       <script type="text/javascript">
   
       			jQuery(document).ready(function() {
                       let event = new Event('oxygenVSBInitToggleJs');
                       document.dispatchEvent(event);
       			});
   
                   document.addEventListener("oxygenVSBInitToggleJs",function(){
                       oxygenVSBInitToggleState();
                   },false);
   
       			oxygenVSBInitToggleState = function() {
   
       				jQuery('.oxy-toggle').each(function() {
   
       					var initial_state = jQuery(this).attr('data-oxy-toggle-initial-state'),
       					   toggle_target = jQuery(this).attr('data-oxy-toggle-target'),
                              active_class = jQuery(this).attr('data-oxy-toggle-active-class');
   
       					if (initial_state == 'closed') {
       						if (!toggle_target) {
       							jQuery(this).next().hide();
       						} else {
       							jQuery(toggle_target).hide();
       						}
       						jQuery(this).children('.oxy-expand-collapse-icon').addClass('oxy-eci-collapsed');
                               jQuery(this).removeClass(active_class)
       					}
                           else {
                               jQuery(this).addClass(active_class)
                           }
       				});
       			}
   
                   jQuery("body").on('click', '.oxy-toggle', function() {
   
                       var toggle_target  = jQuery(this).attr('data-oxy-toggle-target'),
                           active_class   = jQuery(this).attr('data-oxy-toggle-active-class');
   
                       jQuery(this).toggleClass(active_class)
                       jQuery(this).children('.oxy-expand-collapse-icon').toggleClass('oxy-eci-collapsed');
   
                       if (!toggle_target) {
                           jQuery(this).next().toggle();
                       } else {
                           jQuery(toggle_target).toggle();
                       }
   
                       // force 3rd party plugins to rerender things inside the toggle
                       jQuery(window).trigger('resize');
                   });
       		</script>
       ```
   
 * Sometimes I experience issue with wp-admin version and soemtimes have to do chnage
   to frontend to unload.
 * But yeah the code seems generic and is loaded once tabs or accordion is used.
   So not globally hardcoded but once used it’s loaded. So maybe this cause issues?
   But most pages use it in this case.
 * [https://oxygenbuilder.com/try/](https://oxygenbuilder.com/try/) might be helpful
   for your investigation.
    -  This reply was modified 5 years, 5 months ago by [Rookie](https://wordpress.org/support/users/alriksson/).
 *  Thread Starter [Rookie](https://wordpress.org/support/users/alriksson/)
 * (@alriksson)
 * [5 years, 5 months ago](https://wordpress.org/support/topic/fail-to-unload-certain-hardcoded-scripts/#post-13835912)
 * [@gabelivan](https://wordpress.org/support/users/gabelivan/) Any update on this
   one?

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

The topic ‘Fail to unload certain hardcoded scripts’ is closed to new replies.

 * ![](https://ps.w.org/wp-asset-clean-up/assets/icon-256x256.png?rev=1981952)
 * [Asset CleanUp: Page Speed Booster](https://wordpress.org/plugins/wp-asset-clean-up/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-asset-clean-up/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-asset-clean-up/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-asset-clean-up/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-asset-clean-up/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-asset-clean-up/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Rookie](https://wordpress.org/support/users/alriksson/)
 * Last activity: [5 years, 5 months ago](https://wordpress.org/support/topic/fail-to-unload-certain-hardcoded-scripts/#post-13835912)
 * Status: not resolved