Requirejs-config file: app/code/Vendor/Module/view/frontend/requirejs-config.js
var config = {
paths: {
'myfile': "Vendor_Modulename/js/myfile"
},
shim: {
'myfile': {
deps: ['jquery']
}
}
}
Your js file should be in: app/code/Vendor/Module/view/frontend/web/js/myfile.js
Now you can use anywhere in your template file by calling the below method:
<srcipt><script>
require(["jquery","myfile"],function($,myfile){
$(document).ready(function(){
//call your js here...
})
})
</script>