ways to stop scripts: here Google-Maps API: wp_dequeue or wp deregister script?
-
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
<code class=””>
<code class=””>(‘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 :
<code class=””>
<code class=””>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.ww.wp.xz.cn/Function_Reference/wp_deregister_script
https://developer.ww.wp.xz.cn/reference/functions/wp_register_script/
<code class=””>
<code class=””>wp_register_script( string $handle, string|false $src, string[] $deps = array(), string|bool|null $ver = false, array|bool $args = array() ): bo etc. etx
what do you say – which way to choose – which method!?
The topic ‘ways to stop scripts: here Google-Maps API: wp_dequeue or wp deregister script?’ is closed to new replies.