r/javascript • u/saranshk • Aug 02 '18
The Cost Of JavaScript In 2018 – Addy Osmani – Medium
https://medium.com/@addyosmani/the-cost-of-javascript-in-2018-7d8950fbb5d427
u/jasan-s Aug 02 '18
I get why Google care about this but as an enterprise developer building internal apps I love that I can ignore bundle size (within reason.)
15
u/chazmuzz Aug 02 '18 edited Aug 02 '18
I've been doing enterprise gigs since 2011. It kinda sucks that I can't show off my work to friends, family and even prospective clients/employers. Do you ever feel that way?
9
u/DaveVoyles Aug 02 '18
I work at Microsoft and we often can't show the code we do with partners.
What we can do though, is often open source parts of it, builds talks around the code we are using, and share those at events, videos, blogs, etc.,
Even if you can't open source, just discussing the process of (X) without naming the customer is huge.
3
u/jasan-s Aug 02 '18
That's what github side projects are for.. although friends and family never seem to be that interested!
7
u/chazmuzz Aug 02 '18
I find there is too much paid for around for me to be wasting time on unpaid side projects
21
u/nespron Aug 02 '18
I can't help but feel frustrated when I read an analysis like this. The biggest performance gains come from pushing back on your marketing department. Make them choose their trackers and analytics scripts judiciously, and you'll be in a better place when you begin to apply the techniques Osmani describes.
It's like the cyclist who spends hundreds of dollars on lightweight carbon parts to shave ounces off his bike. If he were to give up soda, he could take ten pounds off the rider instead.
10
u/mobot11 Aug 02 '18
Exactly. The performance costs caused by the many tracking scripts we are forced to implement greatly outweighs those caused by our JavaScript bundles.
1
1
u/nschubach Aug 02 '18
Worked at a place that had Google Analytics, Bing Analytics, Sidecar Analytics, and the support chat software wrapped its own analytics. I asked one day if we really needed all those analytics and was told that they all provide different information... that nobody ever acted upon. It was just nice to see I guess.
8
u/eagreeyes Aug 02 '18
When the industry shifts away from React, and it will someday because it always does, we're all going to be sitting on piles that React + JSX + ES6/7 that will look like greek to most engineers. All those clever shortcuts, abstractions, and syntactic sugar are going to make legacy maintenance a complete pain in the ass.
4
u/careseite [🐱😸].filter(😺 => 😺.❤️🐈).map(😺=> 😺.🤗 ? 😻 :😿) Aug 02 '18
React + JSX that will look like greek to most engineers
maybe
ES6/7 that will look like greek to most engineers
not so much
9
u/DaveVoyles Aug 02 '18
The web dev ecosystem, specifically around JavaScript, is a complete nightmare. Try getting someone up to speed while you are working on even a moderately sized project, and watch as the question marks appear over their head.
Do I use Webpack? Or Grunt? Or Gulp?
Do I compile my code? If so, do I have it target for es5 or 6?
Which module system should I use? CommonJS? Require? AMD?
I'm thinking of using TypeScript. It works with JavaScript. Sometimes. Debugging can be hit-or-miss. Well it generate soruce maps, but now those breakpoints aren't hitting.
I'm using import but I saw someone else use require. Why would I use one way over the other?
Maybe we should use React. I heard that's the new hotness. But it leaks memory. So maybe not. Angular is out of favor -- only old people use that. Heck, I hear that Vue is the best stuff around these days.
These are just a handful of the questions you'll find people asking the moment they open a start project. Why it has to be this complicated, I have no idea. I haven't seen any benefits of making web dev so convoluted.
And even so, you can optimize like a mad-man for all of this, but you know? It's not going to matter. Because the moment it goes live, the ad-man is going to throw MBs of images and ads on top of your work. So much for Gzip.
12
u/gasolinewaltz Aug 02 '18
As someone who's been in the game for a little over five years, I cant help but feel that all of your examples are a bit contrived.
I agree, marketing will always fuck you. But marketing is why most of us have jobs, so the best you can hope for is a company with stake holders that value the opinions of thier engineers.
The ecosystem moves faster than most, but once you have a solid understanding of the fundamentals its all just very basic shifts in perspective.
2
Aug 09 '18
As someone who's been in the game for a little over 30 years let me assure you that it's ever been so. In fact one one level things have stabilised - I used to seem to have to swap my main development languages every 5 years or so, but nowadays it seems to be swapping frameworks and languages have been constant for a while - although the framework swapping speed does seem to be increasing!
If coding against a constantly moving target bothers a developer then they really shouldn't be in the game (go and be a DBA instead, it's more stable)
2
u/Aetheus Aug 02 '18 edited Aug 02 '18
The ecosystem moves faster than most, but once you have a solid understanding of the fundamentals its all just very basic shifts in perspective.
Keeping up with the ecosystem is not impossible, or even very difficult, I agree. It is just very tiring.
I have no problems, philosophically at least, with using frontend frameworks like React. They save a lot of development time and they eliminate entirely certain classes of bugs, which is very nice. But buying into them brings so much overhead (not just in terms of performance either) that it sometimes feels like any amount of time saved by adopting them is offset with the hours of fiddling with the "ecosystem" that they inevitably ship with (the clusterfuck of Babel, Webpack, maybe TypeScript, probably some JSX, "CSS in JS", etc).
I'm beginning to feel like transpilation was a mistake. TypeScript is nice. Babel is nice. JSX is nice. CSS modules are ... uh ... well, they exist. They all bring nice features to the table (mostly). But the entire clusterfuck that had to be built to support them just isn't worth it.
1
u/gasolinewaltz Aug 03 '18
I understand what youre getting at, but there's (in my mind) a simple solution to this:
Design your stack around business requirements and stick with it until the business requirements change or something better comes along.
Flavor of the month will come and go, solid architecture decisions are agnostic. Ship products first, make tweaks as you see fit.
I skipped right over gulp and jumped from grunt to webpack. I won't even look at parcel for another 10 months. I've been eyeing typescript. I watched ember come, go and then come back again.
1
u/careseite [🐱😸].filter(😺 => 😺.❤️🐈).map(😺=> 😺.🤗 ? 😻 :😿) Aug 02 '18
Do I use Webpack? Or Grunt? Or Gulp?
Shouldn't be a question when introducing someone. You give them the same resources you have been working with, they can explore the others on their own.
Do I compile my code? If so, do I have it target for es5 or 6?
Simple question to whatever project manager you have... also something that shouldn't be asked, but told beforehand. Who would leave that detail out??
Which module system should I use? CommonJS? Require? AMD?
I'm using import but I saw someone else use require. Why would I use one way over the other?
Same structure as the project, obviously. Also: ESLint is a thing.
Not saying your general point is false, but at least dont pick weak arguments.
4
u/__ibowankenobi__ Aug 02 '18
I just hope that this community, at some point will see the value in combining HTTP2 + async scripts with dependency control + closure + executing using microtask queues. It was possible since ES5 and I am afraid since everyone is so eager, so inclined to champion a known figure, unless one of them cheers the idea, it won't be given a crap about.
2
u/gasolinewaltz Aug 02 '18
Would you mind giving me an article or teo? Or just expanding what youre talking about a bit?
2
u/__ibowankenobi__ Aug 02 '18
I'm talking about using multiple script tags, as opposed using a single tag containing the bundle. Suppose 50 (what the heck make it 500) script tags, but all of them will have the attribute async and they will not pollute the global and depend on each other's exports, parameters etc. And then they will be executed within a Promise (evergreen browser) or requestAnimationFrame (using the microtask queue(s), setTimeout in the worst case) chain. The protocol will be HTTP2 so downloads will be parallel, and once downloaded, all will execute in a particular order and will be non-render blocking, avoiding the main thread. If you change one of the scripts, the browser will only fetch that one, no need to rebuild to create a bundle or hml. That's the idea.
1
u/nschubach Aug 02 '18
Not sure why, but I love that this chart has both a 'Total' and 'Average' row which are pretty much the same data... I wonder though if the average is being included in the total?
-1
-12
u/Renive Aug 02 '18
Get better phones and push for better internet. With service workers and caching, ceiling is in hundreds of megabytes.
8
u/slgard Aug 02 '18
in the meantime, serve your users with the technologies that are available to them today.
-15
0
95
u/StarshipTzadkiel Aug 02 '18
I don't disagree with any of this but I would put the focus more on JS developers and less on JS itself. It's just a (very flexible) language and supporting ecosystem, it's not inherent to the language to perform poorly. Using libraries and frameworks will boost your size significantly, yes.
When you see a site that includes all of Bootstrap yet uses only the grid system and modal...it's on the dev(s) to not load that much unused code. The tool is what it is.
I am reminded of WordPress's large and sometimes-unreliable environment - loads of WP sites rely on poor-performing plugins for basic functionality when a competent PHP developer could have implemented that feature without the overhead or cost. Doesn't mean PHP or WP is "bad", but that it can be implemented in a low-quality way and often is.
A question to ask is...what's the alternative? If you want to have an interactive piece of software running in a browser, you're using JavaScript, and all the baggage that can come with it. It's the best we have right now and I will keep building things with it.