I have a link to the script in my HTML
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCrAbBwliakQCs7vDgLGilKQnicEc0-8hA&callback=initMap&v=weekly" defer></script>
I need to add attribute "defer" in my php when using "wp_dequeue_style"
wp_enqueue_script('google-map', 'https://maps.googleapis.com/maps/api/js?key=AIzaSyCrAbBwliakQCs7vDgLGilKQnicEc0-8hA&callback=initMap&v=weekly', [], $version, true);
is it any options?
2
Answers
You can’t do it using
wp_enqueue_script
you will have to use some other script loader hooks and add the defer.Please check this article it has the explanation and code that will help you.
Please add this in your functions.php file and check again.