Skip Navigation

[Resolved] How can I disable unnecessary code that the toolset inserts without my permission

This thread is resolved. Here is a description of the problem and solution.

Problem: Toolset injects some code automatically in the site for Views and Blocks, and I would like to know how to dequeue that code.

Solution: The Toolset Blocks script frontend.js isn’t enqueued normally, an inline script is added to the page to load the script asynchronously. This can be disabled by adding the following constant to wp-config.php:

define( 'TB_SCRIPT_STYLE_LAZY_LOAD', false );

Then the script itself and accompanying stylesheet can be dequeued normally as desired, like so:

add_action( 'wp_print_scripts', 'ts_debug_scripts' );
function ts_debug_scripts( $handles ){
  wp_dequeue_script( 'toolset-blocks' );
  wp_deregister_style('toolset-blocks');
}
This support ticket is created 2 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by antona-2 2 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#2085355

The code to disable:
<script> window.addEventListener("load",function(){ var c={script:false,link:false}; function ls(s) { if(!['script','link'].includes(s)||c[s]){return;}c[s]=true; var d=document,f=d.getElementsByTagName(s)[0],j=d.createElement(s); if(s==='script'){j.async=true;j.src='/wp-content/plugins/wp-views/vendor/toolset/blocks/public/js/frontend.js?v=1.5.2';}else{ j.rel='stylesheet';j.href='/wp-content/plugins/wp-views/vendor/toolset/blocks/public/css/style.css?v=1.5.2';} f.parentNode.insertBefore(j, f); }; function ex(){ls('script');ls('link')} window.addEventListener("scroll", ex, {once: true}); if (('IntersectionObserver' in window) && ('IntersectionObserverEntry' in window) && ('intersectionRatio' in window.IntersectionObserverEntry.prototype)) { var i = 0, fb = document.querySelectorAll("[class^='tb-']"), o = new IntersectionObserver(es => { es.forEach(e => { o.unobserve(e.target); if (e.intersectionRatio > 0) { ex();o.disconnect();}else{ i++;if(fb.length>i){o.observe(fb[i])}} }) }); if (fb.length) { o.observe(fb[i]) } } }) </script><noscript><link rel="stylesheet" href="/wp-content/plugins/wp-views/vendor/toolset/blocks/public/css/style.css"></noscript>

What needs to be registered in the functions.php file so that this code does not appear on the site?

#2086789

Hello, I'm not aware of an easy way to disable this code but I will ask my 2nd tier support team if it is possible to dequeue it somehow. I'll let you know what I find out when they return tomorrow.

#2088029

It would be great to have in the plugin settings a special option to disable the addition of such scripts and css to the code.

#2088513

The Toolset Blocks script frontend.js isn’t enqueued normally, an inline script is added to the page to load the script asynchronously. This can be disabled by adding the following constant to wp-config.php:

define( 'TB_SCRIPT_STYLE_LAZY_LOAD', false );

Then the script itself and accompanying stylesheet can be dequeued normally as desired, like so:

add_action( 'wp_print_scripts', 'ts_debug_scripts' );
function ts_debug_scripts( $handles ){
  wp_dequeue_script( 'toolset-blocks' );
  wp_deregister_style('toolset-blocks');
}

Let us know if this snippet is not working for you.

#2089201

/wp-content/plugins/wp-views/vendor/toolset/blocks/public/css/style.css

This css is still in the code after applying your recommendations

#2089205

wp_deregister_style('toolset-blocks');

This should have apparently been written in the code.

#2089437

Okay thanks for the update, I'll let my 2nd tier team know that the snippet should be updated to also deregister the stylesheet. Does that completely remove the code, or is anything else overlooked now?

#2089523

My issue is resolved now. Thank you!

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.