We currently have a large phtml file that is essentially a plain JavaScript file, eg.,
<?php
// some conditional check. about 10 lines of code
>
<script>
// here is 1000 lines of JavaScript
</script>
We want so split JavaScript into separate file so editor can have syntax highlight and we can run linters on JS file. What is the best way to split JS file into separate file but at run time still inline JavaScript code (so client doesn't have to fetch separate JS file)?
view/frontend/layout/
?<head> <script src="Vendor_Module::js/newfile.js"/> </head>
and move all script code to this js file.