I want to increase my page speed by deregistering unnecessary external resources. I already managed to remove most of the external scripts, Elementor loads by default on the frontend. However, I can’t remove the jQuery plugin Sticky somehow. I guess it has to do with being a part of Elementor Pro.
I’ve already tried to look under jQuery depencies, however that didn’t work for me.
function remove_jquery_sticky() {
if ( ! is_admin()) {
wp_deregister_script( 'sticky' );
}
}
add_action( 'elementor/frontend/after_register_scripts', 'remove_jquery_sticky' );
I expect the jQuery plugin not to load on the frontend, however it still does.
3
Answers
I have found a solution that works for me. If you've a cleaner solution, please let me know :)
If you know the name of the action that is being added you can use the function
remove_action( $tag, $function_to_remove, $priority )
or you can usewp_dequeue_script( $handle )
https://codex.wordpress.org/Function_Reference/remove_action
https://codex.wordpress.org/Function_Reference/wp_dequeue_script
Elementor and Elementor PRO register and enqueue some scripts with dependences. For remove you need deregister and register again without specific script (example without ‘elementor-sticky’).