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.
-
magento.stackexchange.com/questions/104684/…Khoa Truong– Khoa Truong2016年11月13日 13:14:59 +00:00Commented Nov 13, 2016 at 13:14
-
Appending src_type="url" won't helpKaushal Suthar– Kaushal Suthar2016年11月14日 08:57:54 +00:00Commented Nov 14, 2016 at 8:57
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">
<head>
<script src="https://www.google.com/recaptcha/api.js" src_type="url"/>
</head>
</page>
You need to add this src_type="url"
-
Appending src_type="url" won't helpKaushal Suthar– Kaushal Suthar2016年11月14日 08:57:52 +00:00Commented Nov 14, 2016 at 8:57