Skip Navigation

[Closed] Dequeue extra scripts and resources

This support ticket is created 3 years, 4 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)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 3 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#2096725

Tell us what you are trying to do?
Hi there, my site is currently failing the Google Core Vitals and I'm working through the extra files being loaded and I noticed that Toolset is loading a whole bunch of extra resources that I don't need. This is contributing to my site failing the Core Vitals speed benchmark with Google.

I've added the script from the article below

function cleanup_scripts() {

if ( !is_admin() ) {

wp_dequeue_script( 'views-pagination-script' );
wp_dequeue_script( 'jquery-ui-core' );
wp_dequeue_script( 'jquery-ui-datepicker' );
wp_dequeue_script( 'jquery-ui-datepicker-local' );
wp_dequeue_script( 'wpv-date-front-end-script' );
wp_dequeue_script( 'wpv-front-end-utils' );

}
}
add_action( 'wp_print_scripts', 'cleanup_scripts', 100 );

function cleanup_styles() {

if ( !is_admin() ) {

wp_dequeue_style( 'views-pagination-style' );
wp_dequeue_style( 'views-table-sorting-style' );
wp_dequeue_style( 'wpv_render_css' );

}
}
add_action( 'wp_print_styles', 'cleanup_styles', 100 );

remove_action('wp_print_styles', array($WP_Views, 'add_render_css'));
remove_action('wp_head', 'wpv_add_front_end_js');

Is there any documentation that you are following?
https://toolset.com/forums/topic/why-does-toolset-view-load-13-extra-css-and-js-files-in-the-frontend/

Is there a similar example that we can see?

What is the link to your site?
hidden link

#2097175

Hi, that article is a bit outdated. The recent Blocks 1.5 and 1.5.2 releases (also Views 3.5 and Views 3.5.2) included several resource optimizations, and consolidated several resource files to improve performance. Are you using the latest versions of all Toolset plugins? If so, can you provide more specific information about the files you want to dequeue? I will be glad to take a look if you provide the URLs of those assets.

#2097293
gtmetrix-har-html-2021-06-23-17_28_17.png

I'm not exactly sure on all the names but I don't use any of the views(blocks) functionality. It's just a simple layout of testimonials using Owl carousel which is a separate asset and no pagination. I've attached a screenshot of all the files being loaded in which just seem crazy how many files there are.

#2098075
Screen Shot 2021-06-24 at 10.30.50 AM.png

I've attached a screenshot of all the files being loaded in which just seem crazy how many files there are.
It's not uncommon in WordPress sites, unfortunately, to see this number of JS/CSS assets and many, many more. Each theme and plugin may load some of its own assets, and some enqueue shared assets already baked into WordPress. I see JS/CSS files in this list from Divi, SEOPress, and WordPress in general to name the ones I can recognize by filename. May I ask what URL you are testing in this screenshot? When I visit the live site at hidden link, I see a very different set of assets loaded, including only one CSS and one JS file directly loaded from the Views plugin directories (screenshot attached). I see a handful of JS/CSS assets from litespeed, which I assume are concatenated, minified resources from various other components, but cannot be sure. Am I looking at a different version of the site from the version being tested, and which of the Google Core Vitals tools are you testing with? WebPageTest shows good scores for the site URL I mentioned, other than Security issues (not really related to what we're discussing here).

I don't use any of the views(blocks) functionality.
Are you saying you do not need the Views/Blocks plugin for any reason? In that case, feel free to disable it. It is certainly not required for using Toolset Types, if that's all you need for your site. If you are saying you do not need the features of Views/Blocks in some specific pages of the site but need them in others and cannot deactivate the plugin entirely, you can programmatically dequeue the frontend JS and CSS assets where they are not needed by first adding this snippet to your site's wp-config.php file:

define( 'TB_SCRIPT_STYLE_LAZY_LOAD', false );

...then adding the following code in your child theme's functions.php file. You insert your own custom conditional logic to deregister/dequeue assets based on the current URL or some other criteria of your choosing:

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

The topic ‘[Closed] Dequeue extra scripts and resources’ is closed to new replies.