In default_head_blocks.xml I've loaded following jquery.

<link src="//maps.googleapis.com/maps/api/js"/>
<link src="js/main.js" order="101"/>

Now my situation I want map js loaded to be first but it's not working I've set the order parameter in my custom js but it's not working with external js, Even I tried with requirejs but I'm getting following error in console.

js:85 Uncaught TypeError: Cannot read property 'firstChild' of null(…)

So what can be solution here??

EDIT Even If I place it like following

<link src="//maps.googleapis.com/maps/api/js" src_type="url" />

This won't change anything in order...I want this file to be loaded before my custom file called.


1 Answer 1


Try this,

<?xml version="1.0" ?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <script src="https://www.google.com/recaptcha/api.js" src_type="url"/>

You need to add this src_type="url"

  • Appending src_type="url" won't help Commented Nov 14, 2016 at 8:57

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.