Comments (5)
let
is also slower than var
. Both let
and const
require the VM to generate extra code to do additional checks that potentially throws an error if the variable is used before it's initialized. These checks can result in extreme slowdowns in older VMs and moderate slowdowns in newer VMs.
from esbuild.
Those two code fragments are basically the same size after gzip. If you aren't gzipping your code, then that's likely going to be a bigger win than any tweaks to the minifier can be. And if you are gzipping your code, then your suggestion will have essentially no effect on gzipped code size.
To answer your question: one easy way to avoid inlining is to replace const
for var
. That has the additional benefit of running more quickly as const
has more run-time overhead than var
does (at least when const
is not completely inlined).
from esbuild.
Those two code fragments are basically the same size after gzip. If you aren't gzipping your code, then that's likely going to be a bigger win than any tweaks to the minifier can be. And if you are gzipping your code, then your suggestion will have essentially no effect on gzipped code size.
I knew you will say that! 😃
To answer your question: one easy way to avoid inlining is to replace
const
forvar
.
Very interesting insight, thank you! I see this also works with let
(does it have similar runtime overhead?). Somewhat logical but surprising behavior, actually very useful in my case as I want to prevent substituting constants.
from esbuild.
Thank you, very insightful. As I additionally process the output code with terser, it transpiles everything to var
.
I'm closing the issue then as there's a workaround, and somewhat I agree substituting const is an expected behavior. Thank you!
from esbuild.
Sounds good. Closing this issue then.
from esbuild.
Related Issues (20)
- ESbuild loader Plugin: Dynamic Imports do not contain "with" information HOT 3
- Dynamic imports with string literal templates are not resolved when using tsconfig paths
- Could not resolve "path", could not resolve "os" HOT 3
- Post install script fails with Expected "0.21.5" but got "0.21.4" HOT 4
- Disable resolving url() in stylesheets? HOT 3
- Request to update Go dependency to fix security vulnerabilities HOT 9
- How to work with core-js ? HOT 5
- Is there a way to preserve string delimiters? HOT 5
- Error: The following dependencies are imported but could not be resolved: main.css HOT 3
- Add `conditions` as a `build.resolve` option
- circular dependency not being detected/reported HOT 3
- esm import cjs package with .node file require return a path string HOT 4
- Minified code performs differently for opening a file browser HOT 1
- esbuild-wasm Unable to set globalName,error: -- window name=__dependency__ HOT 5
- `$configDir` may not be working correctly HOT 2
- npm ci with esbuild on different systems HOT 6
- feature request - annotate function code HOT 2
- Dynamic require of "https" is not supported HOT 2
- v0.21.5 api.Build doesn't write bundle to outfile even though it's specified HOT 3
- esbuild 0.22.0 not bundling node ESM modules correctly HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esbuild.