Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link
<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?How to load custom module js file in magento 2?

<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?

<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?

Source Link

<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?