question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reduce file size for Scala.js

See original GitHub issue

I 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 image

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
cquirozcommented, Mar 2, 2020

scalajs-java-locales implemented locales filtering via sbt-locales. I’ll keep this open though as an umbrella for the topic of size reduction

0reactions
cquirozcommented, Sep 1, 2019

That is a great insight, perhaps it could be added to the documentation?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Compilation and optimization pipeline - Scala.js
Fast Optimizing. The size of the JavaScript files produced by blindly concatenating .sjsir files are huge. They are always bigger than 20 MB...
Read more >
Will Scala.js ever produce small bundles? - Stack Overflow
Strictly speaking, it is possible to write a Scala.js application producing only 10 KB or a bit more. But in order to do...
Read more >
Hands-on Scala.js - Haoyi's Programming Blog
Scala.js arguably provides more than either of these libraries. Regardless, there is ongoing work to shrink the size of these executables.
Read more >
Scala.js - Basic tutorial - GitHub Pages
Size is critical for JavaScript code on the web. To compress the compiled code even further, the Scala.js sbt plugin uses the advanced...
Read more >
The Scala Center's roadmap for a Unified Scala.js Ecosystem
As a library author, it's a pain for me to have to change my workflow to accommodate the plugin, so I choose not...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found