News for hackers. Stuff that matters.
Re:Snowpack: Build a web application without a bundler by simplecto on Wednesday January 08, 2020 @06:17PM (#21996843)
I really enjoyed react when it first came out and there was little fussing with browserify (3-4 years ago).

But now this tooling is out of hand. I threw up my hands and found sanity again in simplicity (my username namesake).

  * Django
  * jquery
  * intercoolerjs (https://intercoolerjs.org)
  * plain old docker
It is like war-games. The only winning move is not to play.

Now I deploy apps with no more than 100 lines of JS.

Again, not prescriptive, just my own journey.

Re:Snowpack: Build a web application without a bundler by cr0sh on Wednesday January 08, 2020 @06:40PM (#21996995)
I was once working on a small tool that I tried different iterations of using a small variety of approaches; I tried implementing it in bash, perl, python, ES6 JS (classes and more), and a few other methods (I think at one point I even tried a LibreOffice spreadsheet).

But I kept getting mired and "stuck" in how I should architect things, or what framework to use, or this or that. I eventually decided that I wanted it to be a browser-based app of some sort (thus the road of ES6) - but then I started to wonder what tooling to use there. Lots of questions, etc - and I never got that far with it.

I eventually wised up and realized that it didn't matter what I chose - what I needed was the application to work. Who cares about frameworks, requirejs, css frameworks, etc - I just wanted something working. So I stepped back...and decided to chuck all of that away.

I ended up with a basic webpage, with a script tag and the code inside that - nothing fancy, purely procedural, old-school javascript functions, tied to events. Bare bones, basic.

...and I made real progress for the first time.

Basically, by regressing to the relative simplicity of Javascript back from the 1990s, I was able to get my tool finally going, without having to worry about the last two decades of cruft around that language. Now, I could have also done it using Python or anything else, in the same manner - but again, I wanted it to be browser based.

As you note, my own journey, and not something I'd tell anyone else to do (and certainly not something meant for a production environment!) - but for myself, and my need, this fit the bill. I'm still working on it; I figure when I complete it proper-like, I can go back and refactor it to something more respectable. Or maybe not.

After all, if it works, why try to break it? In the end, I want the results from the tool - who cares what it looks like under the hood, so long as it works.

Re:Snowpack: Build a web application without a bundler by alexdeloy on Wednesday January 08, 2020 @07:07PM (#21997167)
So good to find someone else who went back to the 90ies stack!

After playing around with some react/vue/express/angular/younameit apps for various clients I am more than happy to escape the dependency hell and write efficient code in pure JS that load basically instantly and doesn't need a build environment in the first place. The last straw for me was spending over a day trying to find the right versions for node and all the packages involved to at least get a "legacy app" I inherited running.

I find that I don't even need jQuery anymore, support for things like closest() or a simple document.querySelector is so good that I save those few kb as well.

Re:Snowpack: Build a web application without a bundler by mstade on Wednesday January 08, 2020 @08:01PM (#21997488)
I'm doing this as well, mostly. It's surprisingly productive! I don't use jQuery or anything like that either. For DOM manipulation I've got a little utility module that I'll include in projects. I know what every function does and it's mostly just some convenience wrappers around standard APIs, I have maybe 15-20 functions in total and I don't think any one of them is longer than 20 lines (including comments and white space.)

I've written some reasonably complex apps this way, but I'd probably have a hard time selling this approach to fellow devs, most I've worked with are very entrenched in <insert favorite framework here> and not particularly keen on doing things differently. I can understand and appreciate that point of view, and will acquiesce to the will of the team, but in the past year or so I've had the luxury of being the sole dev on most of the projects I've worked on so this is what I've done and it's been wonderful.

F5 is my compiler, it requires no additional configuration beyond what's already in the HTML, and it's super fast. I love it! :o)

Re:Snowpack: Build a web application without a bundler by bgdkbtv on Wednesday January 08, 2020 @06:32PM (#21996950)
I write react professionally, but for my freelance projects or any personal projects I came to a similar stack when it comes to simplicity.

Laravel NGINX VanillaJS/WebComponents (toying with Svelte right now) MariaDB

Fast prototyping, simple deployment, almost no time spent with tooling.

A recent example with too much tooling I had was with Root's bedrock+trellis+sage. They do make working with WordPress management for a developer (a lot less clicking that with normal WP setup). But the frontend setup, webpack, backend, browserify and all of that is so complicated and slow. I was able to set it up on one machine, but failed to git clone the same project on two others. Scripts would be missing, things wouldn't load etc. Nightmare.

Re:Snowpack: Build a web application without a bundler by vmsp on Wednesday January 08, 2020 @07:09PM (#21997181)
If you're a fan of this type of libs, you should also check out https://stimulusjs.org/ and https://umbrellajs.com/.
Re:Snowpack: Build a web application without a bundler by ComputerGuru on Wednesday January 08, 2020 @07:53PM (#21997452)
This is my first time seeing any of these awesome libraries linked here, but for my money I just spent half an hour reading all the intercooler docs and it looks like a winner. I don’t see the benefit of Umbrella over jQuery when you take into account the browser support and libraries available for the latter, and it seems that intercooler is stimulus + turbo links but on steroids.
Re:Snowpack: Build a web application without a bundler by jturpin on Wednesday January 08, 2020 @07:47PM (#21997426)
These both look cool. I've learned some Vue in the past but I strongly prefer these kinds of small, self contained libraries for my Flask + PicnicCSS + very simple JS apps.
Re:Snowpack: Build a web application without a bundler by brylie on Thursday January 09, 2020 @02:18PM (#22004472)
I mentioned this library in a previous comment, but LiteDOM might be interesting to you as it is somewhat similar to Vue:

https://litedom.js.org/

Re:Snowpack: Build a web application without a bundler by brylie on Thursday January 09, 2020 @02:17PM (#22004451)
LiteDOM also seems very promising:

https://litedom.js.org/

Re:Snowpack: Build a web application without a bundler by ComputerGuru on Wednesday January 08, 2020 @07:50PM (#21997437)
I wrote my own (minimal) library to do what intercooler does in an effort to strictly progressively enhance a UI for dynamic updates while embracing server-side templating and rendering (ASP.NET Core). I can’t believe I didn’t find this at the time! It’s much more thorough and capable than what I wrote, I’m definitely using this going forward, thank you!
Re:Snowpack: Build a web application without a bundler by uncle_j on Wednesday January 08, 2020 @06:52PM (#21997065)
That intercoolerjs looks pretty decent.

With regards to tooling I agree it is too complicated. I really wish that everyone would coalesce around a standard set of tools. But it would be the equivalent of cat herding.

Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @06:21PM (#21996864)
Huh? React tooling options have never been simpler. Literally one command and you're ready to go.
Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @06:35PM (#21996968)
And it pulls hundreds of megabytes of shit behind the scenes with god knows what vulnerabilities & backdoors, the resulting browser bundle is hundreds of kilobytes of crap the browser has to download & parse (instant on a fast machine & internet, less so on a cheap Android device on crappy underground subway Wi-Fi), etc.

This complexity is out of hand. The worst is we now use yet more solutions (for example server-side rendering, which now needs its own Node server and it's yet another thing to deploy in addition to your main backend) just to try and dig ourselves out of the hole we dug in the first place. Imagine if we suddenly decided concrete isn't cool anymore and everyone should use duct tape. Given its obvious shortcomings we now waste time trying to make tape work, going as far as making concrete-reinforced duct tape and calling it the best new thing of the day... instead of just using the "uncool" concrete in the first place.

This guy has a point, for 90% of projects, you don't need React (those who tell you otherwise are trying to justify their career and position because from my experience most React/Vue front-end positions at companies are pointless and just add unneeded complexity).

War story time: a client was building a complex financial product (includes real-time automated trading, etc). The backend was finished but we couldn't test it because despit several months months the React front-end still wasn't ready and days were wasted on basic things like a signup form, displaying the 2FA QR code, user onboarding wizard, etc. Let that sink in for a minute: we could successfully decide when to make transactions worth millions of dollars automatically, but dug a hole so deep on the front-end that we couldn't do basic things that even the first iteration of HTML forms could do just fine 20 years ago. The powers that be didn't want to lose face so they still kept at using that trainwreck of a front-end instead of ripping the whole thing out and rebuilding it using HTML forms in a matter of hours. I didn't stick around to see if they ever finished the project.

Re:Snowpack: Build a web application without a bundler by debaserab2 on Wednesday January 08, 2020 @06:51PM (#21997058)
Just because a new solution is trending doesn't mean you have to figure out how to use it in your tech stack. Evaluate your needs and where it may or may not fit and decide accordingly.

> This complexity is out of hand. The worst is we now use yet more solutions (server-side rendering, which now needs its own Node server and it's yet another thing to deploy) just to try and dig ourselves out of the hole we dug in the first place.

No, someone had a project that required SSR and for reasons important to their project wanted to build out that functionality in node. You don't have to use it just because it's out there if you find you don't have compelling reasons to apply it to your project.

Just because it doesn't fit your project doesn't mean it's useless for everyone else. Your 90% of projects aren't other people's 90% of projects.

Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @06:56PM (#21997091)
SSR was just an example. It's a valid solution, my point is that it's now yet an extra workaround to a problem we created in the first place.

Websites were SSR'd by default back in the day, the backend (with PHP or whatever you had on there) generates some HTML that the browser displayed. Then we decided that wasn't cool anymore and went through this whole clusterfuck of SPAs to justify cool kids' careers and now we're going back full-circle to a way more complex solution with more moving parts of doing exactly what we implicitly had 2 decades ago because we realised cool kids' careers had negative impacts in terms of page load performance.

Re:Snowpack: Build a web application without a bundler by debaserab2 on Wednesday January 08, 2020 @07:07PM (#21997163)
But SSR isn't a core requirement for many applications. Nor is it necessary to build out a purely javascript based stack on the server side to get SSR with a shared React client codebase.

> Then we decided that wasn't cool anymore and went through this whole clusterfuck of SPAs to justify cool kids' careers and now we're going back full-circle to a way more complex solution with more moving parts of doing exactly what we implicitly had 2 decades ago because we realised cool kids' careers had negative impacts in terms of page load performance.

I really don't think the author of most of the tooling in the ES based javascript ecosystem are "cool kids trying to justify their careers". If you actually think that, take a look at the github profiles of some of the contributors for many of these repos. There's a ton of smart people working on these tools. They're not chasing trends. Sometimes complex problems require complex solutions. Sometimes they don't. It really depends on your project. Bemoaning the amount of options available seems like a waste of time.

Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @07:17PM (#21997235)
I never said the authors of big JS projects weren't smart. In fact, anyone that manages to keep their sanity in that environment is by definition smarter than me.

I however stand by my words that most React/Vue/Angular front-end developers in most companies are absolutely unnecessary and are actively detrimental to the project by introducing complexity to justify their position.

Most projects do not have any requirements like real-time UIs that would justify a front-end app and will be just fine with a "boring" backend-rendered UI with some HTML, CSS & forms and will automatically avoid a horde of problems like syncing authentication between your backend & frontend, having to manage a separate build pipeline, server for SSR, etc.

Re:Snowpack: Build a web application without a bundler by debaserab2 on Wednesday January 08, 2020 @07:31PM (#21997326)
> I however stand by my words that most React/Vue/Angular front-end developers in most companies are absolutely unnecessary and are actively detrimental to the project by introducing complexity to justify their position.

I strongly disagree; most of the projects that I worked on a decade ago that lasted more than a few months ended up with ad-hoc frameworks or conventions implemented in vanilla JS or jQuery that varied wildly in quality and changed frequently through the lifespan of the project. In my experience React/Vue/Angular with their generally well engineered and thought-out principles have resulted in a huge boon for productivity for long term projects in a team environment.

> Most projects do not have any requirements like real-time UIs

Whose "most projects" are we talking about here? Yours?

Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @07:56PM (#21997465)
> Whose "most projects" are we talking about here?

Go on a job board, search for React/Vue/Your-Favorite-SPA-framework, go to their website and then see if there are any features that would actually justify an SPA.

Some examples: the Airbnb website, the New Reddit, etc.

Re:Snowpack: Build a web application without a bundler by true_religion on Thursday January 09, 2020 @06:03AM (#22000169)
I would use reddit as a counter example. Sure some the new features could be built without an SPA, but it would be much harder to do so.

They have a full wysgi for theming built in, a real time chat app, a video sharing app, multiple messaging platforms, and methods of bundling multiple subreddits together.

They added all this really fast, due to the nature of the platform being an SPA.

I have the same issue at work. Any given feature in isolation could be done simply as a jQuery plugin, but together the only way to make it seamless is an SPA.

Re:Snowpack: Build a web application without a bundler by Nextgrid on Thursday January 09, 2020 @11:15AM (#22002379)
Did you not compare how much faster & more usable their old platform is compared to the new one? The new one is painful to use.
Re:Snowpack: Build a web application without a bundler by true_religion on Thursday January 09, 2020 @02:28PM (#22004609)
It used to be true. Their first few months of the SPA was really rough on the UX front, but it really improved since then.

They have a good design staff, but there was so many minor decisions made over the years that no knew exactly what was a necessary feature of the UI and what was just fluff.

They needed some real world testing to get a better design.

Re:Snowpack: Build a web application without a bundler by brylie on Thursday January 09, 2020 @02:32PM (#22004651)
Relatedly:

If we don't adopt a framework we end up building one - increasingly of a patchwork of pieces fitting a bit roughly together.

Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @07:22PM (#21997274)
"I hate that React needs a server for SSR. Instead I want a simple setup with a server for SSR."
Re:Snowpack: Build a web application without a bundler by brylie on Thursday January 09, 2020 @02:28PM (#22004606)
SSR just seems like tail chasing, but this time around there is no mature server-side framework (like Django, Laravel, Rails). Maturity, ecosystem cohesion, and higher level abstractions are all casualties along the trail of abandoned work in the name of "scalability" and "modernity".
Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @06:54PM (#21997079)
Hate to break it to you, but servers and server-side rendering existed before React.

Sounds like you're blaming good tools instead of bad developers.

Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @07:02PM (#21997135)
There is no world where a tool or language for which you need hundreds of megabytes of unknown untrusted dependencies of dubious quality is considered a good tool.
Re:Snowpack: Build a web application without a bundler by grumple on Wednesday January 08, 2020 @07:06PM (#21997157)
...what? He was bemoaning React making things far more difficult than they need to be. And I think that’s a fair assessment of the situation. There’s a minimum overhead to maintaining a modern js app that is far higher than maintaining say, a Rails frontend. And it’s more costly for every change.
Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @07:19PM (#21997248)
Rails and React are in no way comparable. They solve entirely different problems.
Re:Snowpack: Build a web application without a bundler by adamrt on Wednesday January 08, 2020 @07:01PM (#21997129)
He's saying that there is client side rendering and now there needs to _also_ be server side rendering to compensate for its shortcomings.
Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @07:07PM (#21997165)
There doesn't need to be server-side rendering to use React. There also doesn't need to be client-side rendering to use React.

Besides, a combo of PHP backend codebase and a jQuery frontend codebase has many more shortcomings than a single React codebase.

Re:Snowpack: Build a web application without a bundler by whostolemyhat on Thursday January 09, 2020 @09:06AM (#22001252)
> And it pulls hundreds of megabytes of shit behind the scenes with god knows what vulnerabilities & backdoors

I assume you roll your own OS then?

Re:Snowpack: Build a web application without a bundler by ummonk on Wednesday January 08, 2020 @06:46PM (#21997019)
Preact is like 5KB.
Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @07:00PM (#21997124)
You do realise that 5KB is bigger than most text content you'd ever display on a webpage? You know how many things can go wrong when trying to download 5KB on flaky public Wi-Fi or overloaded cellular connection? And you're telling me it is no big deal to be loading that with no actual benefit to the user?
Re:Snowpack: Build a web application without a bundler by welly on Wednesday January 08, 2020 @07:31PM (#21997327)
Sorry but 5kb is absolutely nothing for today's Internet connections, public WiFi or overloaded cellular connection or something else, especially if it's provided by a cdn. Yes, it is absolutely no big deal to be loading 5kb. Come on, be serious.
Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @08:01PM (#21997485)
The problem is not the CDN, it's the last mile. You seriously overestimate public Wi-Fi and shit cellular networks; there are times where a simple HTTP request returning dozens of bytes of text will fail. In these moments every byte matters and personally if I'm going to make my user download 5kb of data I will make sure it's content they care about, not a JS framework.

Let's take the example of London Underground's Wi-Fi. It's only available at platforms, not while the train is travelling between stations. When the train arrives into the station it will stay there around 10 seconds. 5 seconds of those are wasted by the phone finding the network and authenticating to it, which means you've already got only 5 seconds before the train goes away and the connection drops off. During those 5 seconds you have lots of apps in the background (push, e-mail sync, background app refresh, etc) that are all fighting for around 1Mbps of bandwidth.

There's also the issue of failing gracefully. If CSS or image loading fails the browser will still display the bare HTML and the user will still have their content in a consumable format. If JS fails to load in an SPA the page is unusable and often shows just a blank screen. If SPA-initiated requests fail it's up to the developer to handle the exception and offer the user a way to retry instead of just giving up and waiting for a page reload.

Re:Snowpack: Build a web application without a bundler by welly on Thursday January 09, 2020 @04:36AM (#21999761)
As someone who used to commute through London on the tube and knows the underground wifi very well, you take on board the limitations of the connection. And you know the connection is going to fluctuate so you're not going to be doing anything serious.

Broken images and incorrectly loaded CSS can also break pages and make them unusuable so where do we draw the line?

I do get your point but on the other hand many sites are using JS frameworks for good reason and 5kb is absolutely nothing to improve the user experience. You really can't complain about the size of a 5kb javascript file in this day and age otherwise let's just revert back to HTML 2 or 3 to cater for all edge cases.

Re:Snowpack: Build a web application without a bundler by SamBam on Thursday January 09, 2020 @10:42AM (#22002080)
Now you're just arguing for the sake of arguing. I get the general rant against huge bulky libraries, but you're picking the wrong hill to die on for 5kb.

Google's logo, one word, 4 colors, is 14kb.

To have a library that gives you a better foundation to build a website on be 5 (actually 3) kb? In what universe is that a bad thing?

Re:Snowpack: Build a web application without a bundler by cfv on Thursday January 09, 2020 @03:35AM (#21999492)
This website's favicon is 7.3kb. What kind of weird edge case are you working for?
Re:Snowpack: Build a web application without a bundler by ummonk on Wednesday January 08, 2020 @10:23PM (#21998271)
That is less data than the logo will take up, and is also less data than, e.g., the raw text in this comments section (compressed with brotli). With proper caching policy, the code bundle also only needs to be downloaded once.
Re:Snowpack: Build a web application without a bundler by robertoandred on Wednesday January 08, 2020 @07:39PM (#21997383)
jQuery is 80kb. How is that better than 5kb?
Re:Snowpack: Build a web application without a bundler by Nextgrid on Wednesday January 08, 2020 @07:59PM (#21997475)
In a lot of cases (especially in today's modern JS and browsers) you don't need jQuery either.
Re:Snowpack: Build a web application without a bundler by djsumdog on Wednesday January 08, 2020 @06:32PM (#21996948)
Does it download 200MB of tools? (Seriously asking; I've contributed to some React apps but have made one from scratch never).
Re:Snowpack: Build a web application without a bundler by zdragnar on Wednesday January 08, 2020 @06:39PM (#21996994)
Create-react-app is pretty heavy, because it includes support for things you may not need or want (css modules, typescript, etc).

Putting together your own light-weight system isnt hard if you are familiar with the problems these tools solve, but unless you have a site so simple that it shouldn't use react anyway, you'll want the power and features that these tools can provide (automatic source splitting for lazy-loading code on route changes, sane management of language files for internationalization, extensive linting rules for even non-js things like accessibility features in html / jsx, automatic image optimizatuon, etc).

Re:Snowpack: Build a web application without a bundler by bovermyer on Wednesday January 08, 2020 @06:56PM (#21997100)
I prefer to just write raw JavaScript, and as little as possible.
Re:Snowpack: Build a web application without a bundler by brylie on Wednesday January 08, 2020 @10:24PM (#21998284)
Dokku gets an honorable mention, as it makes deployment as simple as `git push dokku master`:

http://dokku.viewdocs.io/dokku/

Dokku also uses(Heroku) buildpacks, which are becoming standardized:

https://buildpacks.io/

Re:Snowpack: Build a web application without a bundler by rkangel on Thursday January 09, 2020 @08:57AM (#22001169)
I agree with your goal. Have you looked into Elixir/Phoenix? Phoenix is a great server-side web framework, and with the recent addition of Phoenix LiveView you can do really nice rich client side stuff, but all written server-side in Elixir.

LiveView is an alternate architecture to intercooler.js but with the same goal. There is a standard JS bundle that goes to the client that opens a websocket to the server. You annotate HTML tags (like intercooler) and then handle the events on the server. This is all abstracted away though so you end up writing a controller that looks a lot like a normal server side rendered page.

Re:Snowpack: Build a web application without a bundler by brylie on Wednesday January 08, 2020 @10:21PM (#21998264)
Intercooler js looks really cool! Do you have any suggestions for adding transition animations? E.g. to add smooth in/out for AJAX returned content.
Re:Snowpack: Build a web application without a bundler by hikefast32 on Wednesday January 08, 2020 @10:43PM (#21998377)
You can use CSS for transition animations. Look for “CSS-Based Indicators” in the docs.
Re:Snowpack: Build a web application without a bundler by brylie on Wednesday January 08, 2020 @10:15PM (#21998244)
I'm enjoying developing Django apps with Wagtail CMS:

https://wagtail.io

I have had a great development experience. The Wagtail core team are very active and helpful.

Re:Snowpack: Build a web application without a bundler by djsumdog on Wednesday January 08, 2020 @06:33PM (#21996954)
Intercooler looks neat. I couldn't find anything on their site about supported browsers though.
Re:Snowpack: Build a web application without a bundler by vearwhershuh on Wednesday January 08, 2020 @06:37PM (#21996978)
It depends on jQuery and if you use history support it will need localStorage, so pretty broad browser support.
Re:Snowpack: Build a web application without a bundler by jniedrauer on Wednesday January 08, 2020 @11:12PM (#21998504)
Ironic that intercoolerjs.org is missing functionality unless you allow scripts from code.jquery.com
Re:Snowpack: Build a web application without a bundler by simplecto on Thursday January 09, 2020 @08:14AM (#22000892)
Not sure about that. I simply include jquery then intercooler (both loaded from my server) and then it is off to the races...