Weird load of google maps in modular page

Hello everyone!
I have a weird problem with google maps in a modular page and I hope someone may have a guess on what is causing this.

I have a modular page with a module for showing googlemaps. Since this is the only page with a map I loaded the script only in this module template with:
{% do assets.addJs(‘https://maps.googleapis.com/maps/api/js?key=’, {‘priority’:‘90’,‘loading’: ‘defer’}) %}

Here the problem. On localhost everything is fine, but online the script is not loaded and it doesn’t appear at the bottom. Any ideas?

You are including the javascript within the modular page itself?
Where in the modular page is the javascript being called? It is outside of the content block you are likely using to render the page?

You’re probably missing the maps API key. Check your browser’s console. You should find a javascript error…

@seb3000 I’ve the API key, but I haven’t posted here :wink:

@Sockfuzz Actually I didn’t add the javascript to the modular.html.twig, I added it to the module template map.html.twig that is one of modules in “contacts page”.
Like this:

page folder structure
06.contacts
   _module01
   _module02
   _map     < this is the module where I want to put the map javascript

The structure of my map.html.twig is the following:

map.html.twig

{% do assets.addJs(‘https://maps.googleapis.com/maps/api/js?key=’, {‘priority’:‘90’,‘loading’: ‘defer’}) %}

        <div class="contact-us-area padding-top">
            <div id="googleMap" style="width:100%;height:485px;"></div>
        </div>'

In localhost the script is loaded at the bottom, online it’s not being loaded at all

Do you tried to add 'group':'bottom' ?

I have noted on a repo how to add assets only on specific page, you can take a look at it here: https://github.com/paulmassen/grav-collection#add-a-css-or-js-file-on-a-specific-page

Disable TWIG Caching for the modular page.

Sorry for the delay guys.
@paul actually that solution can not work since it’s not possible to add a block to a module template (it can’t have the extends twig tag)
@chris_jung well I didn’t thought about that and it was a possible solution, unfortunatelly it didn’t worked aah.

Well I made a lot of tests and nothing worked, I’m just going to leave the script in base template for now. If I can find a solution I’ll let you know.

Thanks anyway! :slight_smile: