Skip Navigation

[Resolved] Restricting Toolset scripts to specific pages or sections

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

Problem:
How to restrict Toolset scripts to specific pages or sections
Solution:
you can use the WordPress standard hook "wp_print_scripts" and "wp_print_styles" to dequeue the javascript and css files loaded on frontend.

You can find proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/restricting-toolset-scripts-to-specific-pages-or-sections/#post-625584

Relevant Documentation:

This support ticket is created 6 years, 8 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 5 replies, has 3 voices.

Last updated by Akhil 6 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#625111

Tell us what you are trying to do?

I am creating a classifieds section with toolset plugins as part of a larger site that does not require toolset plugins.

Is there any documentation that you are following?

I have had good luck using your documentation, but I haven't found anything that helps me use toolset for only one part of a site.

bsbclassifieds.wpengine.com - This will be migrated to one part of the later site.

#625160

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - could you please be more specific about your issue - what exactly you want to hide - which sections?

It will be great if you provide brief description for your issue that will help me to guide you in right direction.

#625462
without-types-enabled.png
with-types-enabled.png

Hi Minesh,

Thanks for your timely response. We are putting together a site in which we are using types extensively - extrapolating from your very helpful classifieds example site.

However, we were benchmarking site speed, and the homepage of the site, which does not rely at all on toolset plugins, and when we enable toolset plugins, the homepage takes a significant speed hit.

Is there anything you know that I can do about this speed hit?

I have attached screenshots of the GTMetrix report that I am working from.

Thank you!

#625584

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - I think you can use the WordPress standard hook wp_print_scripts and wp_print_styles to dequeue the javascript and css files loaded on frontent .

This hook just runs before the scripts and style links being printed to the page. Used with a late priority it will ensure you are attempting to dequeue them once they have been enqueued. You need to find the unwanted scripts and styles that is loaded on home page and dequeue it accordingly.

Here is a simple example I used to dequeue the pagination script and stylesheet from the front-end:

function remove_unwanted_scripts() {
 
    if ( is_home() ) {
 
        /// add scripts to dequeue
// Remove: /res/js/wpv-pagination-embedded.js
wp_dequeue_script( 'views-pagination-script' );
 
    }
}
add_action( 'wp_print_scripts', 'remove_unwanted_scripts', 100 );
 
function remove_unwanted_styles() {
 
    if ( is_home() ) {
 
       // add styles to dequeue
       
       // Remove: /res/css/wpv-pagination.css
        wp_dequeue_style( 'views-pagination-style' );
        
        // Remove: /common/toolset-forms/css/wpt-jquery-ui/datepicker.css
        wp_dequeue_style( 'wptoolset-field-datepicker');

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

You can adjust the above code as per your requirement.

#625751

Thank you for this code. I can apply this approach.

#625814

is it ok to use gonzales plugin for this purpose ?