Remove/Filter Duplicate Link

wordpress

#1

Hello All,

Happy New Year Everyone! I have a question.

How do you remove/filter a duplicate link from a Theme and a Plugin? I have a google map link on both theme and plugin. Now I want to use only one link, any advice or any link of a snippet to fix it.

Thank you very much!


#2

I think you can use deregister, if you know the handle of one specific script: https://codex.wordpress.org/Function_Reference/wp_deregister_script or simply look into your theme functions.php file and remove that link from there or relevant included files.


#3

You can do like @GomalThemes said using the wp_deregister_script to remove the script from loading if you know the handle name. There is another hacky way of doing this using this the global $wp_scripts you will be able to access this before the wp_enqueue_script is finished executing, here you can check by regex if you want but is not recommended.

Example:

add_action( ‘wp_enqueue_scripts’, function() {
global $wp_scripts;
//$wp_scripts->registered
}, 100 );