Any way to reduce bundle size after tree shaking?
See original GitHub issueAfter correctly using tree shaking (I’m using about 20 icons, no layers) and setting:
addCss: false,
useLayers: false,
useLayersText: false,
in module config, my top size in bundle is fontawesome-svg-core which includes some unuseful code for my needs and it seems there’s no way to limit its size. Am I missing something? thanks
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Reduce JavaScript payloads with tree shaking - web.dev
Tree shaking addresses this by taking advantage of how static import statements pull in ... bundle isn't bad, but it should be noted...
Read more >Optimize your bundle size by eliminating dead code / tree ...
Today, I want to talk about a very effective method to optimize your bundle size called Tree Shaking. Traditionally, we install a module...
Read more >Reduce bundle size / improve tree shaking #2843 - GitHub
Reduce bundle size / improve tree shaking. ... Reanimated's bundle size is currently massive, and it doesn't have any optimizations for tree shaking....
Read more >Tree-Shaking: A Reference Guide - Smashing Magazine
Simply put, tree-shaking means removing unreachable code (also known as dead code) from a bundle. As Webpack version 3's documentation states: “ ...
Read more >5 Methods to Reduce JavaScript Bundle Size - Bits and Pieces
5 Methods to Reduce JavaScript Bundle Size · 1. Code Splitting with Webpack · 2. Using Webpack Plugins for Tree Shaking · 3....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Note you can use babel-plugin-transform-imports lib to this automatically for you on build:
import { faApple } from '@fortawesome/free-brands-svg-icons'
Edit: my extracted example above includes handling of tree shaking for lodash so you can just remove that if you don’t use it
Tree shaking is disabled in dev, so it imports the whole set in development. I suggest changing the code to do one import per icon (adding the icon name at the end of the import path) to only import icons that are used. This would improve page load time in dev which is especially relevant when not accessing the page via localost but via a proxy. In production it is more performant to do a single import as unused icons are tree shaked.