realtebo's avatar

Mix: how to combine multiple js into one?

Actually my mix starts as this:

mix
    .js('resources/assets/js/model.js', 'public/js')
    .js('resources/assets/js/family.js', 'public/js')
    .js('resources/assets/js/home.js', 'public/js')
    .js('resources/assets/js/device_search.js', 'public/js')
    .js('resources/assets/js/app.js', 'public/js')

this because app.js is loaded in the main app blade layout, but other js are used only in specific pages.

I'm asking if is possible to combine all .js files into one webpacked .js file and continue using mix to load single file.

I explain. In family.blade.php I load family.js in this way

    @section('page_specific_scripts')

        <script src="{{ mix('js/family.js') }}"></script>

    @endsection

I prefer to have a single app.js file, So I can avoid to include single scripts. but actally I don't know how to use mix to merge all my .js files into a single app.js file

What do you think?

0 likes
1 reply
jlrdw's avatar

As nice as mix sounds, you are better off on a small to medium site just loading the js used on the page it's needed.

Please or to participate in this conversation.