Answer the question
In order to leave comments, you need to log in
How to enable async defer options when loading a script?
Hello, from the documentation for connecting google map, you need to write the following line:
<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap"
async defer>
</script>
$this->registerJsFile('https://maps.googleapis.com/maps/api/js?key='.Yii::$app->params['google']['map_api_key'].'&callback=initMap', ['position' => $this::POS_END]);
Answer the question
In order to leave comments, you need to log in
Try like this:
$this->registerJsFile(
'link',
['position' => $this::POS_END, 'async'=>true, 'defer'=>true]);
$this->registerJsFile(
'link',
['position' => $this::POS_END, 'async'=>'async', 'defer'=>'defer']);
$this->registerJsFile('https://maps.googleapis.com/maps/api/js?key='.Yii::$app->params['google']['map_api_key'].'&callback=initMap', [
'position' => $this::POS_END,
'async' => 'async',
'defer' => 'defer'
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question