I am trying to add references to external JS/CSS files, and for the most of them, all works fine. However as soon as I try and add an external script with parameters in the URL (for example &sensor=false&libraries=geometry), it seems to cause issues. In my case, it's causing Google maps not to detect the API key. I tried replacing the & with %26, but this didn't work.

Adding the script directly into the template works, just not through the XML, which is what I need in this case.


<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="1column">
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/themes/redmond/jquery-ui.min.css" src_type="url"/>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js" src_type="url"/>
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js" src_type="url"/>
        <script src="https://maps.google.com/maps/api/js?key=MYAPIKEY&sensor=false&libraries=geometry" src_type="url"/>

1 Answer 1


Managed to get around this by creating a block referencing a separate phtml file and adding the scripts there instead. Bit of a faff, but works. Other suggestions welcome!

        <referenceBlock name="head.additional">
            <block class="Magento\Framework\View\Element\Template" name="frontuser" template="Magento_Theme::html/header/scripts.phtml"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.