Hi,
I'm trying to remove the script "toolset-common-es-frontend.js" from loading in front-end where it's not needed at all:
I used the instructions from here: https://toolset.com/forums/topic/is-codemirror-really-needed-in-front-end/ to display all the Toolset scripts and thier handles.
I'm searching for 'common-es' in that list, and the only one I find is this one:
[cred-form-block-js] => Toolset_Script Object
(
[handle] => cred-form-block-js
[path] => hidden link.../cred-frontend-editor/public/js/blocks.editor.js
[deps] => Array
(
[0] => wp-editor
[1] => toolset-common-es
)
[ver] => 2.6.12
[in_footer] =>
)
It already does not look the same as the path is different (the one that's displayed is in "hidden link.../cred-frontend-editor/vendor/toolset/common-es/public/toolset-common-es-frontend.js").
Adding the handle to wp_enqueue_scripts does not do anything:
add_action( 'wp_enqueue_scripts', 'remove_default_scripts', 20 );
function remove_default_scripts() {
wp_dequeue_script( 'cred-form-block-js' );
wp_deregister_script( 'cred-form-block-js' );
}
This is the only toolset script that I can't manage to remove. Can you help please?
Thank you.
Hello Luo Yang,
Thanks for the reply, but it's not working.
Here is my code (I added everything that was in the post you suggested, plus what I had before):
add_action( 'wp_enqueue_scripts', 'remove_default_scripts', 1, 999 );
function remove_default_scripts() {
wp_dequeue_script( 'toolset_select2' );
wp_dequeue_script( 'toolset_select2' );
wp_deregister_script( 'toolset_select2' );
wp_dequeue_style( 'toolset-select2-css' );
wp_deregister_style( 'toolset-select2-css' );
wp_dequeue_script( 'toolset-codemirror-script' );
wp_deregister_script( 'toolset-codemirror-script' );
wp_dequeue_script( 'jquery-ui' );
wp_dequeue_script( 'wptoolset-field-date' );
wp_dequeue_script( 'cred-form-block-js' );
wp_deregister_script( 'cred-form-block-js' );
wp_dequeue_style( 'toolset-common-es' );
wp_deregister_style( 'toolset-common-es' );
wp_dequeue_script( 'toolset-common-es-frontend-js' );
wp_deregister_script( 'toolset-common-es-frontend-js' );
wp_dequeue_script( 'toolset-common-es-masonry' );
wp_dequeue_script( 'wptoolset-field-date' );
wp_dequeue_script( 'views-blocks-frontend' );
wp_dequeue_style( 'toolset_blocks-style-css' );
wp_deregister_style( 'toolset_blocks-style-css' );
wp_dequeue_style( 'views-pagination-style' );
wp_deregister_style( 'views-pagination-style' );
}
And I still see this in the page code:
<script type='text/javascript' src='.../cred-frontend-editor/vendor/toolset/common-es/public/toolset-common-es-frontend.js?ver=161000' id='toolset-common-es-frontend-js'></script>
How do I remove it?
Thanks
Since it is a custom codes problem, please provide a test site with the same problem, also point out the problem page URL and where I can edit your custom PHP codes, I can setup a demo for you
Thanks for the details, I have done below modifications in your website, edit 2019 theme file functions.php, add below codes in the bottom:
add_action( 'wp_enqueue_scripts', 'ts_dequeue_scripts', 1, 999 );
add_action( 'wp_print_scripts', 'ts_dequeue_scripts', 1, 99 );
add_action( 'wp_print_footer_scripts', 'ts_dequeue_scripts', 1, 99 );
function ts_dequeue_scripts(){
if(is_admin()){
return;
}
wp_dequeue_script( 'wptoolset-field-date' );
wp_dequeue_script( 'views-blocks-frontend' );
wp_dequeue_script( 'toolset-common-es-masonry' );
wp_dequeue_script( 'toolset-common-es-frontend' ); // this line is for toolset-common-es-frontend.js
wp_dequeue_style( 'toolset-common-es' );
wp_deregister_style( 'toolset-common-es' );
wp_dequeue_style( 'toolset_blocks-style-css' );
wp_deregister_style( 'toolset_blocks-style-css' );
wp_dequeue_style( 'views-pagination-style' );
wp_deregister_style( 'views-pagination-style' );
wp_dequeue_style( 'toolset-select2-css' );
wp_deregister_style( 'toolset-select2-css' );
}
Above codes will remove all Toolset JS/CSS files from frontend, you can customize it as what you want.
Hello Luo,
I see it's working. Thanks for your help.
Have a nice day!