https://laravel.com/docs/5.6/mix#working-with-scripts
Mix provides several features to help you work with your JavaScript files, such as compiling ECMAScript 2015, module bundling, minification, and concatenating plain JavaScript files. Even better, this all works seamlessly, without requiring an ounce of custom configuration:
mix.js('resources/assets/js/app.js', 'public/js');With this single line of code, you may now take advantage of:
- ES2015 syntax.
- Modules
- Compilation of .vue files.
- Minification for production environments.
Similar to combining stylesheets with mix.styles(), you may also combine and minify any number of JavaScript files with the scripts() method:
mix.scripts([ 'public/js/admin.js', 'public/js/dashboard.js' ], 'public/js/all.js');This option is particularly useful for legacy projects where you don't require Webpack compilation for your JavaScript.
In essence, .scripts takes scripts and just puts all of them into a single file, whereas .js compiles babel and modules and shit like that into JS that all browsers can run.