@thebigk If you aren't using Bootstrap you could easily remove jQuery ...and Lodash. Both of those libraries should halve that size at lease. Granted 305k is nothing these days. Average webpage size as of 2019 is about 3MB. Yes, 3MB! If you dont need Axios, kill that too. Laravel doesn't use these... they just include them if you want to use them.
Jan 14, 2020
3
Level 13
Laravel Mix and Tree Shaking JavaScript
I'm curious to know if we need to explicitly enable tree shaking in Laravel Mix. Even with npm run prod, the size of my app.min.js is abou ~305 Kb!
I'm writing very minimal custom JS, and here''s all I'm using -
window.$ = window.jQuery = require('jquery');
window._ = require('lodash');
window.axios = require('axios');
import Echo from 'laravel-echo'; // I need this
window.Pusher = require('pusher-js'); // I need this
I think this is most of what Laravel uses. I was wondering if tree-shaking would bring the overall size down. Would appreciate suggestions / recommendations.
Level 67
2 likes
Please or to participate in this conversation.