How Lodash Serves 400K Monthly Visitors with Offline-First Performance on Netlify
Lodash is one of the most popular JS libraries in the world with more than 2 billion downloads. It accounts for 4% of npm’s weekly download traffic and it’s directly depended upon by more than 27,000 packages and indirectly depended upon by 100,000 packages (30% of npm packages). It’s used by more than Underscore, React, Ember & Angular 2. Combined. Read more about it and why John Dalton & Co. chose Netlify for Lodash.com.
Key stats & highlights
- 30%of all npm packages depend on Lodash
- 4%of npm's weekly download traffic
- 400Kmonthly page views
What is it?
Lodash is JavaScript utility library. After 4 years of having a PHP based website it was time for a redesign. I wanted the site to be open source & run on a gh-pages friendly stack. Netlify took things to the next level. Lodash.com uses a service worker to download the entire site for offline use on your first visit. It also uses resource hints (prefetch, preconnect, preload, & prerender) for speedier page loads. [The site gets more than 400,000 page views a month.] Resource hints that I compiled with the Netlify build cmd into a headers file. The build cmd invokes a Gulp task to generate app icons, headers, redirects, compile JS, & minify resources. I use custom headers to enforce security headers like CSP too.
One of the cool bits is that we’re actually compiling in the _redirects into the service worker so that redirects work even when offline. It also makes query strings pass through for redirects too.
Why Netlify?
I originally chose Netlify because of its HTTPS support for custom domains. After trying it I quickly found that it offered a freedom of build process, jekyll plugins, redirects, & header configs that ended up being critical to lodash.com.
Favorite Feature?
I love how painless everything is. Setting up HTTPS, redirects, headers, GeoIP, build processes were all super simple. And if I had a question it was answered fast. (You all rock. I’m spreading the word.)
| Netlify Features Used | Tools & Frameworks Used |
|---|---|
| Redirect Rules | Grunt |
| Rewrite Rules | Babel |
| Proxy Rules | Jekyll |
| Custom HTTP Headers | React |
| Cached Dependencies | Sass |
| Git Integration | |
| Outbound Webhooks | |
| Outbound Integrations | |
| Continuous Delivery | |
| Rollbacks | |
| Web UI | |
| Deploy previews | |
| HTTPS |