dev-resources.site
for different kinds of informations.
Lighter LoDash Builds for Laravel
Published at
1/5/2021
Categories
laravel
lodash
performance
Author
mike_hasarms
Author
12 person written this
mike_hasarms
open
Laravel projects often include the LoDash JavaScript utility library. It contains handy utilities, however if you don't need its entire suite you may be serving unnecessary JS to your users that you never run.
LoDash supports custom builds to avoid this problem, and it's fairly easy to modify your Laravel's bootstrap.js file trim down the features you're loading.
Default resources/js/bootstrap.js
window._ = require('lodash'); // 71.1K (gzipped: 24.6K)
Customizing the build
In my case I was only using the throttle and debounce helpers from LoDash. This can be mapped to the window lodash object (typically _) like so:
window._ = require('lodash/core') // 14K (gzipped: 5.3K)
window._.debounce = require('lodash/debounce') // 3.5K (gzipped: 1.4K)
window._.throttle = require('lodash/throttle') // 3.7K (gzipped: 1.4K)
My application JS can then call _.debounce()
and _.throttle()
for those functions with a significant saving to my JS bundle size.
lodash Article's
30 articles in total
lodash._merge vs Defu
read article
Lodash - a javascript power tool
read article
Learn Lodash _.drop - Creates a slice of array with n elements dropped from the beginning.
read article
Reducing Bundle size of a Frontend application by optimizing Lodash imports
read article
How to Use Lodash with Vue In short
read article
Force Lodash Import Scope
read article
Useful Lodash Methods
read article
Why Lodash?
read article
Eslint rule to restrict imports
read article
Lodash Debounce
read article
Type Safe GroupBy In TypeScript
read article
15 useful Lodash methods for everyday coding
read article
A very simple introduction to Functional Programming
read article
How to use Lodash debounce method?
read article
Lodash: _.isEmpty() - Check falsy values
read article
JavaScript - Some very useful lodash/fp functions
read article
setState in useEffect loops the application
read article
Making lodash function get type safe
read article
Lodash pour JS
read article
Functional composition and lodash
read article
Lighter LoDash Builds for Laravel
currently reading
JavaScript Utility Libraries
read article
NodeJS Module: Lodash
read article
Lodash import - done Right!
read article
Shortcut to use lodash library
read article
Building APIs with Json-Server, Faker and Lodash
read article
Lodash chaining alternative
read article
Debouncing (lodash) with React
read article
Use lodash.debounce inside a function component in React
read article
Beware of Mutation in Spread & React Hooks and How Can You Fix It
read article
Featured ones: