by lousken · 4y ago · 0 comments
Like you have drupal with bunch of modules, it's slow as hell so you put redis caching. It's faster but not as fast, so you add varnish on top, so you don't even have to touch the php code unless you make a change.
But then you've never solved the problem, you just hide it two layers deep.
And same with javascript - 85% of sites are visit would work perfectly fine without any javascript. Loading would've been instant, and you don't even need ajax if you can spit html document fast enough - the browser makes it seamless anyways. But no, instead, we do animations and slow down the time to interaction because it's fine sitting on 1Gbit connection waiting for your slow backend part that's not cacheable.
JS isn't bad, it just feels like people think it can solve anything while not seeing issues it adds.
So to rise up a few steps on the Google results page, people turned to serving empty pages with a small JavaScript (which finished loading fast - so bonus points from Google) which then starts pulling in the actual content.
Dear Big-G: Thanks a lot for your hard work, you've really done something.
Most web apps dont have pretenses of being simple. They want to use tools that have room for growth, that have deep capabilities.
And they want to use the really good tools & libraries & technologies that will be used on more complex efforts. Specializing in being lightweight, narrowing the scope of your skills & capabilities is less attractive than getting good at something that works & ideally will also be fast in all cases.
I think it's good to reflect nack to 2014, when React was coming out, & think of what rapid development looked like. Hand manipulating dom trees, course grained re-rendering by setting el.innerHTML,... React and the virtual dom were a huge huge performance win. Some up-front load price, but an amazing boon to rapid rapid developmemt, grossly reducing the scope of concerns one had to think about in webdev, & massively speeding up rendering/updates at the same time.
React isnt the smallest but holy shit it propelled us into a massively massively faster world. Where development is just so stinking much faster/easier, where there are so mamy less bugs & memory leaks. Thanks react.
So why focus on a niche, special purpose skill set? Why go back to hard mode? Is a 30kB preact bundle actually any kind of problem? Is a 100kB react bundle really a problem?
> Loading would've been instant, and you don't even need ajax if you can spit html document fast enough - the browser makes it seamless anyways. But no, instead, we do animations and slow down the time to interaction
Because it's javascript we can often run the same code on the backend, & store & cache our documents or if it's light weight enough just render it (with already started/initialized workers). Hence: server side rendering (ssr).
SSR is very prevalent, actively supported out of the box in newer JS libraries/frameworks like Next. React has had support for "hydrating" a SSR page on the front end for a while, but required some investmemt & didnt just work out of the box.
Im very mixed here, about performance in general. On the one hand I want us chasing technical excellence, being fast. But I also see two things, one, that waiting for a second isnt the worst. Second, a huge amount of the slowness is ads and trackers, is shitty other people prpolems that businesses just accept, and developers at a company dont get much say in. Why would we spend iterations dropping load times from 2s to 0.4s when the damned trackers are still gonna make the site take 5s to load anyways?
No, that's completely false.
Most web "apps" are just text and images, and would better be thought of as documents, which after all is what the web is for. Re-inventing that out of massive piles of JS is strictly worse than what we already had, and in fact still have if only we would choose to use it.
Yeah, sure, there are definitely real app-y things on the web, and here on HN we're biased towards those as mental reference points because they're cutting edge and exciting. But those things are emphatically NOT "most" of what the web is.
React never made development faster.. easier to manage complex state but not faster development.
React hides all that away. The virtual-dom just works. Event handlers all get faithfully reconnected. You never end up accidentally having multiple copies of content or having deleted too much content. As opposed to the DOM's native retained mode rendering, React gives a much simpler immediate mode rendering.
And it's often faster. It's easy to do too much work, to end up replacing more than you need to when you are hand-working the DOM. React's diffing algorithm is quite effective at doing just what updates actually needed be done, where-as before I as tech lead would have to go re-walk through my teammates code & tune & optimize it, fix some of the gross inefficiencies.
Working the DOM used to be a complex & subtle art. A lot of simple stuff you could just do & it was ok. The API was never delightful, even with jQuery. But there was so much latent knowledge, so many particulars, so many hazards. It, in my view, made even simple things much faster to develop.
I'm not saying SPAs should always be used because in most cases they shouldn't, but a well optimised SPA should in theory be quicker and provide UX improvements to the user.
There is a trend in OSS SW development to "continously improve " programs. This means that the program stays mostly the same but it gets over time a "gui improvement" which brings almost nothing new but a lot of libraries and bloat. Two programs that stroke me were Xaos ( which got a QT dependency) and Xsnow. Maybe jwz was right that every program evolves until it can send email.
I've been building a webapp with Python/Django and HTMX, it works like a charm.
[0] - https://htmx.org