options to stop scripts: here Google-Maps API: wp_dequeue or wp deregister script

[ad_1]

How to use wp\_dequeue to keep a script from loading in WordPress: …or are there more options here we can use.

**background:** The theme author is loading the Google Maps API but it isn’t being used on the site so I want to dequeue it in the child theme’s functions.php. They don’t offer an option to simply disable it within the theme settings.

Would someone mind helping me out with some ideas about the options we have here:

​

* a. we could comment it out in the parents theme or
* b. dequeue it in the child theme? and what about the options to
* c. deregister it

​

so there are lots of options here: the wp\_dequeue code

**questions:**

isnt it technically more efficient to comment it out in the parent theme or dequeue it in the child theme? I know the inherent problems with modifying the parent theme code.

regarding the option … we could work with the

(‘bazien-google-maps’, ‘https://maps.googleapis.com/maps/api/js?kewp_enqueue_script(‘bazien-google-maps’, ‘https://maps.googleapis.com/maps/api/js?ke

**but wait:** isnt it the best WordPress way, we ‘ll need to **deregister** it in the child theme. to do so, use the following :

wp_deregister_script( ‘bazien-google-maps’ );

**conclusio:;** it’s more efficient to comment it in the parent theme, because this way we don’t load the script to “unload” it after. But, an update might appear somedays, so it’s more secure to disable it in the child theme.

i am not sure if the above ideas and musings are correct. what do you say…

​

See the cod WordPress for more informations aboubt registering scripts and styles:

here and informations about deregistering: here

Function Reference/wp deregister script: [https://codex.wordpress.org/Function\_Reference/wp\_deregister\_script])

[https://developer.wordpress.org/reference/functions/wp\_register\_script/])

wp_register_script( string $handle, string|false $src, string[] $deps = array(), string|bool|null $ver = false, array|bool $args = array() ): bo

​

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer