You just need to add these files:
ModuleVendor/ModuleName/view/frontend/layout/default.xml
or
ModuleVendor/ModuleName/view/frontend/layout/<frontName>_<controllerName>_<actionName>.xml
File content:
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head>
<link src="ModuleVendor_ModuleName/js/my_js.js"/>
</head>
</page>
JS file:
ModuleVendor/ModuleName/view/frontend/web/js/my_js.js
JS Content:
require([
"jquery"
], function($){
//<![CDATA[
$(document).ready(function() {
console.log('jquery loaded with success!');
});
//]]>
});