Save 9.71 kb minified by removing 147 static named Colors
- Dominant language
- JavaScript
- Stars
- 15.7k
- Forks
- 3.9k
- Avg merge
- 4d 6h
- Merged PRs (30d)
- 34
Description
I noticed 147 named static colors located in `Core/Color.js`. Removing them saved 9,71kb minified in bundle size.
Aside from one or two uses in the core library, they seem to only be used in sandcastle examples and specs, leading me to believe they could do with being extracted or adapted.
An adaption could be to extend `Color.fromCssColorString('string')` to also accept color names: instead of using `Color.PINK` we could have `Color.fromCssColorString('pink')`.
In `Color.fromCssColorString` you could get the color through a canvas object and cache it by name. We did this in `Paper.js` and it works well: https://github.com/paperjs/paper.js/blob/e5d7bafd39db546e6c78bdbd89212c1685e05e1b/src/style/Color.js#L111
`Color.fromCssColorString` could also be shortened to `Color.fromCss`..
Contributor guide
Research direction
Review Core/Color.js and its references in Sandcastle examples and specs. Compare the proposed removal or extraction with extending Color.fromCssColorString and the canvas-based approach; the issue does not establish which direction is required. Done should be defined as an agreed API change with updated references or specs and a measured minified-size result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100