Tree-shaking ready API
See original GitHub issueRight now library exports one big class with everything inside.
It is bad for website performance because webapp JS bundle will contain all methods of Color.js even if user use only a few of them.
Modern JS bundler has tree-shaking feature. If you will move rare (or all) methods to separated functions with separated export, JS bundler will keep only used functions in the JS bundle.
I am talking about something like:
import { contrast } from 'colorjs.io'
contrast(color)
I understand that this feature requires a full refactoring and will not be implemented soon. Just an idea for better web performance.
Color spaces could be tree-shaked as well. Here is an example from culori
.
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Tree Shaking - webpack
Tree shaking is a term commonly used in the JavaScript context for dead-code elimination. It relies on the static structure of ES2015 module...
Read more >Performance Tests | ReadyAPI Documentation
Create and run automated functional, load and security tests for REST and SOAP APIs. Virtualize APIs and run the mocks.
Read more >Build a Tree-Shaking Utility in JavaScript | by Chidume Nnamdi
Bringing it to programming, tree-shaking involves removing dead code. Dead code is code that is declared but not used. Here are a few...
Read more >Untitled
Gurbilas patshahi 10, Gambar origami kupu-kupu, Poison dart tree frog care, Fandrop reddit, ... Lvl 50 barbarian skill build pve, Ready api free...
Read more >lbY - ALBA.Net
Emilio badiola zapateria, Ready api maven, Dodge fitness center front desk, Wnbull, ... Antoni forrellad 101, Coral tree bonsai care, Boys girls zico, ......
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
Even if it’s not tree-shakeable, it’s still modular, as in, you can import only the modules you need. Don’t forget that not all users use bundlers.
OOP does not have the same runtime performance at all. I wish it did! When I switched the API locally to use object literals instead of
Color
instances the performance increase was huge (my benchmark went from 1400ms to 750ms!). There was literally no other change, just not creatingColor
instances and passing object literals around instead was that much faster.Just to clarify. For
bad web perfomance
I mean that OOP is forcing to bloat JS bundle size by adding unnecessary functions to website JS file.I think OOP has the same runtime performance. This issue is addressing loading performance and my dream to have less JS on modern websites.