In Magento 2, you need to add and declare your js file via RequireJS
So:
app/design/frontend/Codazon/fastest/requirejs-config.js
var config = {
map: {
'*': {
myscript: 'js/my_custom'
}
}
};
app/design/frontend/Codazon/fastest/web/js/my_custom.js
define(['jquery'], function($){
"use strict";
return function myscript()
{
alert("Yes, it woooorks!");
}
});
app/design/frontend/Codazon/fastest/Magento_Theme/templates/{yourfile}.phtml
<script>
require(['jquery', 'myscript'], function($, myscript) {
myscript();
});
</script>
PS you also need to:
clean the cache => php bin/magento c:c
clean var/view_preprocessed
content => rm -rf var/view_preprocessed/*
clean pub/static
content => rm -rf pub/static/*
deploy the static content = php bin/magento setup:static-content:deploy -f
Good luck!