4 ms·
Wdym?? 50% is a big deal
by dagelf 2y ago
Wdym?? 50% is a big deal
- bluGill 2y ago50% size savings isn't important to the people who pay for it. They pay at most pennies for 100% savings (that is somehow all the functionality in zero bytes - not worth anything to those paying the bills)
- tyre 2y agoSize savings translates to latency improvements which directly affects conversion rates. Smaller size isn’t about reducing costs but increased revenue. People care.
- soared 2y agoAgreed - often a CTO of an ecom site is very very focused on site speed and has it as their #1 priority since it directly increases revenue.
- fwip 2y agoNote that this proof-of-concept implementation saves latency on first load, but may add latency at surprising points while using the website. Any user invoking a rarely-used function would see a delay before the javascript executes, without the traditional UI affordances (spinners etc) to indicate that the application was waiting on the network. Further, these secretly-slow paths may change from visit to visit. Many users know how to "wait for the app to be ready," but the traditional expectation is that once it's loaded, the page/app will work, and any further delays will be signposted. I'm sure it works great when you've got high-speed internet, but might break things unacceptably for users on mobile or satellite connections.
- vlovich123 2y ago> without the traditional UI affordances (spinners etc) to indicate that the application was waiting on the network. This part is obviously trivially solvable. I think the same basic idea is going to at some point make it but it’ll have to be through explicit annotations first and then there will be tooling to automatically do this for your code based upon historical visits where you get to tune the % of visitors that get additional fetches. Also, you could probably fetch the split off script in the background anyway as a prefetch + download everything rather than just 1 function at a time (or even downloading related groups of functions together) The idea has lots of merit and you just have to execute it right.
- avodonosov 2y agoI agree with most of your comment, but don't get what you mean about explicit annotations. Note that most of the unused code is located in libraries, not in the app code directly.
- vlovich123 2y agosplit async function handle_button_press() { … } This would cause the bundler to inject a split point & know how to hide that + know what needs bundling and what doesn’t. GWT pioneered almost 20 years ago although not a fan of the syntax they invented to keep everything running within stock Java syntax: https://www.gwtproject.org/doc/latest/DevGuideCodeSplitting.html https://www.gwtproject.org/doc/latest/DevGuideCodeSplitting....
- avodonosov 2y agoWhy do you want them explicit in the code? The tooling producing such annotaion based on historical visits whould constantly change the annotated set of functions, I suspect, whith app versions evolving. Note, the inactive code parts are very often in 3rd party libraries. Some are also in your own libraries shared between your different application. So the same shared library whould need one set of split-annotated functions for one app, and another set for another app. So these conflicting sets of annotations can not live in the library source code simultaneously.
- vlovich123 2y agoFor example the automated system could take your non-split codebase & inject splits at any async function & self-optimize as needed. The manual annotation support would be to get the ecosystem going as an initial step because I suspect targeting auto-optimizing right from the get go may be too big a pill to swallow.
- avodonosov 2y agoOnly the first user who hits a rarely used execution point may experience the noticeable latency, if he also has slow internet, etc. As soon as the user executes a rarely used function, the information is about this fact is sent to the server and it includes this function into the active set to be send to future users. In the video I manually initiate re-generation of the "active" and the "rest" scripts, but the most primitive MVP was supposed to schedule re-generation of the scripts when receiving info that some previously unseen functions are executed in browser. Obviously, if the idea is developed further, the first user's experience may also be improved - a spinner shown. Pre-loading the inactive set of functions in background may also be considered (pros: it allows to avoid latency for users ho invoke rare functionality, cons: we lose the savings of the traffic and browser memory and cpu for compiling the likely unneded code). (BTW, further development of the idea includes to splitting the code more granularity than just "active" / "inactive". E.g. active in the first 5 seconds after opening the page loaded immediately, likely to be active soon, active but rarely called - the later two these parts definitely need to be loaded in background)
- bluGill 2y agoWho? anyone who is on a slow internet connection or who has a slow device can tell you they don't care. Or maybe they do but features are far more important. I guess if things are slow on a top of the line device withia fast connection they would care.
- avodonosov 2y agoWhy big deal? 50% is just a big O of the original size :) If we consider overall Internet traffic, which is dominated by video and images, the size of javascript transmitted is negligible. Savings of memory and cpu for end user's browser? Maybe, but our software at all layers is so bloated, without need, just carelessly, that I'm not sure working of such javascript savings is useful - any resources saved will be eaten by something else immediately. For an application developer or operator, the 50% savings of javascript size are probably not worth dealing with some tool that dynamically prunes the app code, raising questions about privacy and security. I though through the security and privacy questions, but who would want to even spend attention on these considerations? As I mention in the README at github, a Microsoft researcher investigated the same approach earlier, but Microsoft haven't taken it anywhere. There was a commercial company offering this approach of javascript minification as a product, complete product. As well as other optimizations, like image size, etc. Their proxy embedded special "agent" code into the app which inspected the device and reported to server what image sizes are optimal for user, what js functions are invoked. And the server prepared optimized versions of app for various devices. Javascript was "streamed" in batches of only functions needed by the app. Now the company is dissolved - that's why the website is unavailable. Wikipedia says they were bought out by Akamai - https://en.wikipedia.org/wiki/Instart https://en.wikipedia.org/wiki/Instart. But I don't see any traces of this approach in the today's Akamai offerings. I contacted several companies, in CDN business and others, trying to interest them in the idea and get very modest funding for a couple more months of my time to work on this (I was working on this in the end of a long break from payed work and was running out of savings). Didn't find anyone ready to take part. This all may be signs that possibility of such an optimization is not valuable enough for users.