0

I don't want to put this script tag in the header of my html:

<script src="https://cdn.jsdelivr.net/npm/places.js@1.7.3"></script>

The main reason is the block that would cause on loading the entire page.

I want to load the script thus:

var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://cdn.jsdelivr.net/npm/places.js@1.7.3';
document.body.appendChild(script);

and I would like can add ?callback=init_input to the js URL to initialize, after places.js was loaded completely, the input element. Is possible?

I know this option is available in Google Maps API but I don't want use it.

Thank you,

Regards

jlgsoftware
  • 172
  • 8

1 Answers1

1

this is not specific to Algolia Places or Google Maps but on how to load a script asynchronously and have a callback. It is answered on SO already: Asynchronous Script Loading Callback

vvo
  • 2,653
  • 23
  • 30