Reduce file size for Scala.js
See original GitHub issueI am looking forward a way to get the benefits of java.time
API and reduce the Scala.js-generated file size at same time. I have started evaluating sbt-tzdb v0.1 for that purpose.
I could save averagely 560KB in size (fullOptJS
, no gzipped) in my several projects, by removing timezone DB with zonesFilter := { (z:String) => false}
. That is 25%~40% savings for my projects.
(Note: I suppose my projects require no timezone DB, since my code base uses only OffsetDateTime
, LocalDate
and Duration
right now)
I also investigated why some project can save 40%, but other can save only 25%. My observation shows that my projects can save additional 747KB averagely, if DateTimeFormatter
usage is eliminated completely. I suppose that there are huge amounts of locales for DateTimeFormatter
as similar as timezone DB.
So… it would be great if one can filter locales for DateTimeFormatter
in common with timezone DB. (Sorry in advance, in case of my assumption regarding DateTimeFormatter
is incorrect)
The below is my observation of file size reduction in my projects.
Project | Total (KB) | Rest of code (KB) | TimeZoneDB (KB) | DateTimeFormatter (KB) |
---|---|---|---|---|
A | 2465 | 1153 | 560 | 752 |
B | 2286 | 978 | 560 | 748 |
C | 2246 | 939 | 560 | 747 |
D | 2237 | 930 | 560 | 747 |
E | 2166 | 862 | 560 | 744 |
F | 2140 | 835 | 560 | 745 |
G | 2130 | 825 | 560 | 745 |
H | 2113 | 808 | 560 | 745 |
I | 2105 | 801 | 559 | 745 |
J | 2083 | 779 | 559 | 745 |
K | 1311 | 753 | 557 | 0 |
L | 1307 | 749 | 557 | 0 |
M | 1283 | 725 | 557 | 0 |
N | 1271 | 713 | 557 | 0 |
Total
=Rest of code
+TimeZoneDB
+DateTimeFormatter
The below chart illustrates the above table
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (5 by maintainers)
Top GitHub Comments
scalajs-java-locales
implemented locales filtering viasbt-locales
. I’ll keep this open though as an umbrella for the topic of size reductionThat is a great insight, perhaps it could be added to the documentation?