<head>
<css src="My_Module::css/style.css"/>
<script src="My_Module::js/script.js" />
</head>
Here is the example. However, you need to take into account, that this script.js
will be loaded synchronously, unlike all core scripts, like jquery.js
(that are loaded via requirejs
) so you can't use for example $
in your script.js
.
If you do want to use all core scripts features, register your script using requirejs-config.js
. Good explanation is here How to load custom module js file in magento 2?