I did added JS file from design layout update from Admin CMS page- > Design
layout update XML , but it showing jQuery is not defined error, When I view source , these files are being added before the requireJS file.
How to add JS from Admin->Content->Pages ->Open CMS page -> Design ->"layout update XML" ?
<head>
<script src="js/pi.googleMapStyles.js" order="100"/>
<script src="http://maps.google.com/maps/api/js?sensor=false" src_type="url" order="101"/>
<script src="js/jquery.gmap.min.js" order="102"/>
<script src="js/pi.global.js" order="103"/><script src="js/pi.init.map.js" order="104"/>
</head>
Thanks
Best Answer
You must quit what you have done so far in the XML layout.
You need
requirejs-config.js
in this pathapp/design/frontend/VendorName/Theme/
with bellow content:OR
You need
requirejs-config.js
in this path/app/design/frontend/VendorName/Theme/web/js/
with bellow content:In a template you can call it:
OR
In a template you can call it:
You can add for any CMS Pages (from admin) a template file in
Layout Update XML
You can add for a test in
test.phtml
file fromMagento_Theme
in your current theme:You can add for a test in
js_file_name.js
file fromMagento_Theme
in your current theme:After seeing your test work, you can change how you want it.