I'm using default/Magento_Theme/layout/default_head_blocks.xml to add CSS and JS. In developer mode, CSS is being added to static files but JS and files are not.
<?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>
<link src="js/menu.js"></link>
<link src="js/iehover-fix.js"></link>
</head>
</page>
2 Answers 2
Try using the script tag and specifying the module:
<script src="Magento_Theme::js/menu.js"/>
<script src="Magento_Theme::js/iehover-fix.js"/>
answered Jul 24, 2020 at 10:48
Ben Crook
15.8k4 gold badges53 silver badges105 bronze badges
-
I tried this but Magento_Theme:: was not rendering a pathSam– Sam2020年07月27日 07:18:36 +00:00Commented Jul 27, 2020 at 7:18
My /web folder was not in the correct folder. It should be themename/default/web I had themename/default/Magento_Theme/web
default