improv: avoid function that dont use `this` within class in packages used by web to better support minification
See original GitHub issuesee https://github.com/open-telemetry/opentelemetry-js/pull/2014/files#r598699521
Some packages where private is used:
- https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-instrumentation-fetch/src/fetch.ts#L119
- https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-instrumentation-xml-http-request/src/xhr.ts#L102
- https://github.com/open-telemetry/opentelemetry-js/blob/main/packages/opentelemetry-core/src/trace/sampler/TraceIdRatioBasedSampler.ts
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
Favor functions over classes for better minification
In this tip, we'll explain why JavaScript functions minify better than classes with real examples.
Read more >Stop Using JavaScript Classes! - DEV Community
It is true that many like using classes in JS because the constructor function allows for easy dependency injection, where we pass in ......
Read more >Webpack's removes classnames when minifying/uglifying ES6 ...
Webpack's removes classnames when minifying/uglifying ES6 code with inheritance: There's MVCE code which we try to minify/uglify: Class Child:.
Read more >Stop Using JavaScript Classes! - Medium
It is true that many like using classes in JS because the constructor function allows for easy dependency injection, where we pass in...
Read more >How to disable webpack minification for classes names
Minification pluin. You can use 'keep_classnames' option provided by the minification plugin to keep the class names intact.
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

The thing is that a good minifier can do much more so any of such “improvements” would rather be a job for minification. We could go back to es5 so it would even minify more as we will not have things that are part of es6 and when converted quite often there are extra things which are not needed, much nicer usage of prototype without some extra overhead etc. etc. I think we might sacrifice too much gaining too little. I would be in position of comparing things very precisely with many different minification libraries, then do some refactoring then compare again. Until then I would like to avoid doing any improvements just by guessing and saying “it will minify better”. We should make very solid comparisons before proceeding with anything like this we should depends on solid numbers - which change do what and with what minifier we get what.
This issue was closed because it has been stale for 14 days with no activity.