I am wondering what is the best way to include a javascript in a modular template. For example, I am making a modular that is a Google Map. There are a couple javascript files that I have to add to the bottom of the page. I only want to javascript to be included if the Google Map modular is on the page. I added them into a block, but that just adds the javascripts twice. I know this should be obvious to me, but I am just not sure what the best way to tackle this is.
Best thing is to add it in the javascripts
block of the top level modular.html.twig
file like this:
{% extends 'partials/base.html.twig' %}
{% block javascripts %}
{{ parent() }}
{% do assets.add('theme://js/your-custom-js.min.js') %}
{% endblock %}
...