News for hackers. Stuff that matters.
Re:Can You Afford It? Real-World Web Performance Budgets by virmundi on Friday October 27, 2017 @09:24PM (#15573493)
Do we need all this JS? I’m starting to look back at classic web development where you had a server rendered mvc style app. There was a controller and templates populated on the server. Every page was a full rerender, but it was small html. Proper caching kept the minimal CSS and images on the client for a regular session under 30 minutes. This seems better.

I know we switched because front end experts told us that users found the full refreshes annoying. They said that users really wanted native desktop like seamless change pages. Never did I see proof of these claimed. Is the modern JS based design our cubicle moment? Did we get suckered in by experts making productivity claims with nothing to back them up?

Re:Can You Afford It? Real-World Web Performance Budgets by feelin_googley on Saturday October 28, 2017 @12:33AM (#15573998)
"Do we need all this JS?"

I know at least one user who is asking this same question. He does not believe it is needed.

Is it possible that "what users want" and what developers want may be two different things? Could developers have wants that are unique to developers?

Purely anecdotal but I do not know any fellow users who "want javascript". I know many who do not want a number of common annoyances though. And I know these hassles are in many cases enabled via javascript.

The tactic leveraged against users is to tell them they need javascript for some thing to work. Then users want it. But I think really they just want the thing to work. They have no particular affection for javascript, let alone any knowledge of why they need it.

One thing I have observed over the years the web has existed early 1990's to today is that users can adapt to anything. Whether it was learning keyboard shortcuts on the console and using text-only programs like Pine, or running www searches that took minutes to finish, or communicating with 140 characters or less, or working with tiny touchscreens and horribly slow web pages and mobile apps. Many more examples if I gave it some more thought. From what I have seen, users accept what they are given and find a way to make it work.

Re:Can You Afford It? Real-World Web Performance Budgets by aaron-lebo on Saturday October 28, 2017 @01:50AM (#15574132)
How do you notify a user of errors in input without a complete page refresh if you do not use Javascript (ignoring the most basic HTML stuff)? Without at least some scripting capability, you're talking about making the experience worse for the user to the benefit (ease of the request/response model) of the developer.

Don't throw the baby out with the bathwater. It is the responsibility of devs to use technology well. You don't want all of this JS, but you do want some of it.

Too many people are making their assumptions about what is possible and what JS is capable of based upon views of web development that are 5-10 years out of date or based on bad software. Bad software is endemic to the industry, it's not representative of any single tech stack.

Re:Can You Afford It? Real-World Web Performance Budgets by ehnto on Saturday October 28, 2017 @04:17AM (#15574422)
You just let the page refresh. It's really not that much different. I am not saying don't use JS for UX improvements mind you. But your comment suggests that any other approach makes no sense. If you have a massive form that has 12 fields then it would be a huge help, but just a couple of text fields? Why replicate the backend validation in client side JS when it's already there on the backend? Then you would have to maintain two code pathways in two different languages in two different locations if you need to update the validation rules. Where simple works, pick simple.

5 years ago was 2013, there were some pretty great things going on in the web in 2013. Don't lose sight of lessons learned by previous work either. A new shiny framework doesn't automatically make it better practice.

While we are reinventing the wheel in client side JS we should make sure to remember that it has probably been done before, software has been around for decades, the web as well, and to think the best of it has only just happened in the last five years is a bit misguided.

Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Saturday October 28, 2017 @07:18AM (#15574751)
This. You can't trust client-side validation anyway, so you need to have some server-side. So why not just let the page refresh, and then add a tiny bit of JavaScript that'll send off the form via AJAX to validation?

Suddenly, the site becomes solid, lightweight, and supports everyone. That's what I think people used to call "progressive enhancement".

Re:Can You Afford It? Real-World Web Performance Budgets by mrighele on Saturday October 28, 2017 @08:03AM (#15574865)
I would love to have a way to tell the browser "don't throw away the current DOM, Just apply the differences". It would work nicely in non-js page to make the experience smooth (and would probably work terribly if there was a lot of J's, of course)
Re:Can You Afford It? Real-World Web Performance Budgets by nojvek on Saturday October 28, 2017 @01:06PM (#15575811)
This. Every major client lib out there uses some variant of vdom. If this dom diffing was natively supported, browser would request with current dom hash and server could efficiently reply with a diff that both server and client can compute to be the same new hash.

If it's forms. Client calls server with base hash + changes made by client and server replies with. Base hash + new diff to apply. The new diff includes validation changes.

It's trees and diffs all the way down.

Re:Can You Afford It? Real-World Web Performance Budgets by pcmaffey on Saturday October 28, 2017 @01:10PM (#15575827)
This is exactly what React's virtual DOM does. Maybe the future is making the virtual DOM native to the browser?

Bundle React with Chrome? Or how about a browser package manager that could cache and reuse all these common js libraries used on so many sites?

Re:Can You Afford It? Real-World Web Performance Budgets by discreditable on Saturday October 28, 2017 @09:17PM (#15577567)
DecentralEyes does just that.
Re:Can You Afford It? Real-World Web Performance Budgets by grogs on Sunday October 29, 2017 @07:38PM (#15582192)
Sounds like PJAX.
Re:Can You Afford It? Real-World Web Performance Budgets by nawitus on Saturday October 28, 2017 @08:12AM (#15574889)
Page refresh takes a longer time than client-side validation.
Re:Can You Afford It? Real-World Web Performance Budgets by gjjrfcbugxbhf on Saturday October 28, 2017 @08:54AM (#15574994)
But you still need to do the server side valuation.
Re:Can You Afford It? Real-World Web Performance Budgets by Can_Not on Saturday October 28, 2017 @11:37AM (#15575458)
That doesn't detract from the value of client side validation, which is that it will be faster from the client's perspective and reduce server load.
Re:Can You Afford It? Real-World Web Performance Budgets by christophilus on Saturday October 28, 2017 @10:35AM (#15575258)
Yes, but from the end-user perspective, it's nice to not have to do a round-trip to find out that you entered something wrong.
Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Sunday October 29, 2017 @07:03AM (#15578863)
Fair enough.

Still, validating a form client-side doesn't require a JavaScript framework; it would only require the server to send small snippets of JS for each field with the form.

Re:Can You Afford It? Real-World Web Performance Budgets by nawitus on Saturday October 28, 2017 @08:11AM (#15574888)
Needing a page refresh for input validation degrades experience.

"Then you would have to maintain two code pathways in two different languages in two different locations if you need to update the validation rules."

Not necessarily. You can use the same exact code, in the same location written in the same language.

Re:Can You Afford It? Real-World Web Performance Budgets by ehnto on Saturday October 28, 2017 @08:26AM (#15574925)
But by how much and does it actually matter? It's also a pretty small example. The problem of complexity outstripping benefits only grows the more you inspect the frontend landscape.

My main point is just that the implication that JS is required otherwise the UX will be unbearable is false. It's also really easy to mess up the UX with JS and I see it constantly. I would take a fast form post over a cumbersome JS powered experience any day.

Re:Can You Afford It? Real-World Web Performance Budgets by mattmanser on Saturday October 28, 2017 @05:38AM (#15574553)
Well, you don't need a SPA to do that at all. You don't have to do the validation client-side, you can still get the server to do it with some extremely simple javascript.

You can render server-side, then switch it to an ajax post in javascript. On submit, post the form back in ajax (a simple `.serialize()`) and if there's a validation error in the form, return the HTML form back in the response with the validation errors and replace it in the DOM.

Virtually instant feedback, no page reload, no 30 second initial SPA load.

In ASP.Net MVC, for example, this is as trivial as changing the `Layout` property of the page in the controller, the full layout for GETs, no layout in POSTs.

Technically you don't even have to support progressive enhancement, but it's so trivial in most frameworks you may as well.

I believe Rails has a built in turbo feature which essentially does this and more.

Example ts code, though usually put more in to disable double clicks and add a loading spinner:

    onSubmit = (e: JQueryEventObject) => {
        e.preventDefault();
        let $form = $(e.currentTarget);
        $.ajax({
            type: $form.attr("method"),
            url: $form.attr("action"),
            data: $form.serialize()
        })
        .done(() => {
            //do something
        })
        .fail((e) => {
            if (e.status == 400) {
                $(".js-form-wrapper").html(e.responseText);
                this.wireUpControls();
            } else {
                //handle error
            }
        })
    }
And wire it up on initialize with:

    $("#your-form").submit(this.onSubmit);
Re:Can You Afford It? Real-World Web Performance Budgets by nawitus on Saturday October 28, 2017 @08:10AM (#15574885)
The comment said "no Javascript", no "no SPA".
Re:Can You Afford It? Real-World Web Performance Budgets by jaggederest on Saturday October 28, 2017 @02:24AM (#15574200)
> How do you notify a user of errors in input without a complete page refresh if you do not use Javascript (ignoring the most basic HTML stuff)?

Well, it used to be that submitting a form and rendering errors on the server took the same ~100ms that evaluating a javascript framework validation does now, and so it was... not a problem.

If you mean "leaving aside the most trivial html stuff" to include things like html5 inputs, that's the most significant part of what Javascript provides in form validation.

Re:Can You Afford It? Real-World Web Performance Budgets by aaron-lebo on Saturday October 28, 2017 @02:33AM (#15574220)
You're glamorizing old web. Old web had the same quality issues, most form submissions were not taking 100 ms and JS validation does not (have to) take 100 ms today.

If you exaggerate the numbers, you can't make any useful comparisons.

Re:Can You Afford It? Real-World Web Performance Budgets by vecinu on Saturday October 28, 2017 @02:46AM (#15574242)
What about all of the information that was already in the submitted form?

We can now keep the user's state and inform them of errors in a way that is more difficult with server-ride rendering.

Re:Can You Afford It? Real-World Web Performance Budgets by bildung on Saturday October 28, 2017 @03:32AM (#15574334)
> What about all of the information that was already in the submitted form?

Of course the form gets returned from server validation will all user input prefilled? At least with Django that's the default behaviour.

Re:Can You Afford It? Real-World Web Performance Budgets by DCoder on Saturday October 28, 2017 @09:10AM (#15575029)
Does "all user input prefilled" include file uploads?
Re:Can You Afford It? Real-World Web Performance Budgets by hawski on Saturday October 28, 2017 @02:39PM (#15576183)
It's not complicated. Server could offer to use already uploaded file or selecting a new one. Identifying it with session cookie or some kind of file hash.
Re:Can You Afford It? Real-World Web Performance Budgets by digi_owl on Saturday October 28, 2017 @03:09AM (#15574289)
> Could developers have wants that are unique to developers?

There seems to be a sizable portion of this, and far from limited to the web world.

That said, some of it may also come from the managerial level. This thanks to cargo culting akin to the offshoring fever a decade or two back.

meaning that management is pushing for something to be done in a certain way because they read about some big name corp doing the same, and wanting the company to appear "aggressive" to investors...

Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Saturday October 28, 2017 @07:25AM (#15574768)
I'd say it's half fashion and half business incentives. JS frameworks are fashionable, every kid learns JS and Node now, and this leads to what I see as a big part of programmer population suffering from acute "only-got-hammer-everything-is-nails" syndrome. But business incentives play a big part too. It's easier to make a shitty SPA than a well-engineered site, but all the shittiness gets externalized on the users, so companies don't care - they get to be little quicker to market, but they don't have to pay for the worldwide waste of electricity and bandwidth they cause.

(Not to mention user frustration. Mainstream webdev doesn't give a damn about that either.)

Re:Can You Afford It? Real-World Web Performance Budgets by jasode on Saturday October 28, 2017 @07:33AM (#15574794)
>I do not know any fellow users who "want javascript". [...] They have no particular affection for javascript, let alone any knowledge of why they need it.

Framing it as end users "do/don't want javascript" isn't helpful for analyzing the advantages/disadvantages of javascript. Obviously, end users don't think of it that way.

We could also say that we don't know any users who "want polycarbonate on their face". That's true, but they do want clear 20/20 vision and we just happen to use polycarbonate as the material that combines the attributes of light weight and inexpensive manufacturing compared to glass.

Nobody wants to "ingest fungus poop" either. Except they do because that's what beer is.

Users also don't want a "30 minute barrage of explosions 5 feet from their body", but they do indirectly want that because they would rather drive a car to the store instead of walk. (Some might extract the wrong idea from that example and insist that we shouldn't be dependent on fossil fuels anyway. Well, people also don't want "volatile chemicals" either which is what lithium batteries are. They also don't want a steel tube shoved up their butt which is what bicycles are.)

(To get back closer to the tech world, end users also didn't ask for "HTML" or "want CSS" or "HTTP" either. They don't think in those terms.)

You're right that they don't want "javascript" per se. What they want is a "fluid experience" in the UI. We happen to use javascript to provide that fluidity.

>I know many who do not want a number of common annoyances though. And I know these hassles are in many cases enabled via javascript.

True. But it ignores the benefits to users that javascript enables. Things like airplanes also bring hassles such as noise but that ignores the fact that people wouldn't want to give up flying because planes also enable convenience.

Therefore, people do want javascript -- indirectly. They want autocomplete in amazon and netflix search fields. They want smooth map repositioning in Google Maps without page reloads. They want up/down voting buttons and expand/collapse outlines to work in stackoverflow, reddit, HN without jarring page reloads. Many pages in wikipedia also work better with javascript.

Yes, the abuses and misuses of javascript that hijacks scrolling or javascript that breaks apart a single page article across 20 screens with tracking and ads are annoyances we don't want. However, it shouldn't keep us from having a balanced discussion that includes how javascript improves the web experience for the average user. The uncompromising insistence on avoiding of client-side javascript in favor of server-side page regeneration&reload is hostile to the user. Many web users do not browse from desktops with fast fiber optic connections. They browse from mobile phones with ~500+ round-trip latency.[1]

Like most of you, I'm a "power user" so I should be a prime example of an uber geek who "doesn't need javascript". And yet, I use regex101.com every week that relies on javascript. It would be a total hassle if I had to press "submit" everytime I changed a character to experiment with regexes.

[1] https://serverfault.com/a/573815

Re:Can You Afford It? Real-World Web Performance Budgets by iamthepieman on Friday October 27, 2017 @11:54PM (#15573912)
I agree with you for content sites or primarily consumption driven apps but I haven't written one of those in 8 years. I'm currently working on an application that we are having to purposefully keep features out of, not because they are slowing the page down, or increasing TTI, but because we risk offending our business partners by building a one for one replacement of their multi-thousand dollar per seat desktop software. There's just no getting around the MB of JavaScript we need for this app. And for this type of application, we are much more concerned about the speed of individual actions on the page than page load. The site still loads faster than the desktop application opens.
Re:Can You Afford It? Real-World Web Performance Budgets by davidgh on Saturday October 28, 2017 @06:44AM (#15574671)
This. Set aside the performance of the initial load for a moment. When I interact with the SPAs we’ve built in recent years, I am still shocked how snappy they are as I perform actions throughout the site. Every “pageview” requires the download of a tiny REST API response and comparably tiny HTML fragment. As a user - that experience is a pure delight compared to a full blown page re-load, re-download and re-render with every action.

As a user it infuriates me when I fill out a long form, hit submit and find out I forgot to select the proper “Mr. Mrs. Ms” title and my password, credit card number and PIN have all be blown away.

As a user I’m willing to pay a few more seconds upfront for snappy and seamless interactions as I use the app.

I think the mistake that is more often committed (and where I myself as a user have less patience) is treating everything that can be accessed via URL as an “app”. If the user is coming to just download bytes, don’t build an app. An app is only justified when a user is coming to manipulate data.

Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Saturday October 28, 2017 @07:29AM (#15574781)
> As a user it infuriates me when I fill out a long form, hit submit and find out I forgot to select the proper “Mr. Mrs. Ms” title and my password, credit card number and PIN have all be blown away.

I'm quite sure this is a sign of poor development, regardless of the form being validated on the server or the client. There is no reason for the server not to send back a fully pre-populated form.

Re:Can You Afford It? Real-World Web Performance Budgets by Can_Not on Saturday October 28, 2017 @01:10PM (#15575831)
Credit card info, passwords...
Re:Can You Afford It? Real-World Web Performance Budgets by naasking on Saturday October 28, 2017 @01:23PM (#15575882)
You're already submitting it to the server. It's no less secure sending it back if there's a problem.
Re:Can You Afford It? Real-World Web Performance Budgets by zbentley on Saturday October 28, 2017 @02:55PM (#15576267)
This comment displays a worrying misunderstanding of web security. Sending passwords (or credit card numbers or other scary stuff) in plaintext over the wire is bad. Hash them securely (well, as securely as you can on the client side). Sending them twice is worse. Storing them with the session data on the backend so that they can be sent back to the client to repopulate a form is way worse, since more than one webserver may be handling a session, that plaintext data will have to be stored in a centralized database (e.g. memcached), which is really really bad, even if that storage is temporary.

Some web forms get around this by just sending back the lengths of the individual fields so they can be masked when the form is repopulated, but that's less common and is something that doesn't occur to lots of developers (store the length, but don't send the whole string). Instead, it's easier to follow the mantra of "never store the passwords in plaintext, never send them over the wire in plaintext". Which is why most web forms clear out the sensitive fields when repopulated via the server.

TL;DR it is much, much less secure to do this.

Re:Can You Afford It? Real-World Web Performance Budgets by naasking on Sunday October 29, 2017 @02:18AM (#15578181)
> This comment displays a worrying misunderstanding of web security. Sending passwords (or credit card numbers or other scary stuff) in plaintext over the wire is bad

What are you talking about? Who said anything about plaintext? And no one said anything about sessions either.

If you're submitting to the server in plaintext, then returning in plaintext is no less secure, but you're stupid for not submitting over https which is free.

If you're submitting to the server over https then it's definitely no less secure to return the data.

Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Sunday October 29, 2017 @02:23PM (#15580532)
Think you're a bit confused about how it all works. There is no need to use plaintext, we'll assume we're using https by default. You are already sending the data from the client to the server, I can as well echo it back with a couple of validation errors.

I don't see the security hole in this situation, you do realise that regardless of the obfuscation you see in your password input fields, which by the way only protects from over-the-shoulder peeking, you are willingly sending data to the server and it will end up there unencrypted anyway. Otherwise there wouldn't be possible to do any operation at all.

Re:Can You Afford It? Real-World Web Performance Budgets by Can_Not on Sunday October 29, 2017 @04:25PM (#15581225)
Security operates in layers. TLS isn't the end-all, be-all for security. It's one layer that prevents a category of attack vectors. Every extra unnecessary sending or storing of sensitive data is an attack vector.
Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Sunday October 29, 2017 @06:31PM (#15581873)
Again, we're not storing anything. And in our case TLS is the layer we're using for protecting our data in-transit. You rely on it as a client when you send the form to the server.

Can you give me an example where POST-ing a form would be secure but responding with the data adds another attack vector? They're both protected by the same "layer" of security, isn't it? How is one more vulnerable than the other?

Re:Can You Afford It? Real-World Web Performance Budgets by setr on Sunday October 29, 2017 @09:47PM (#15582612)
What he's suggesting is that you never send the password to the server, you only send the hash.

The password itself never leaves the client, and never hits the network.

Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Monday October 30, 2017 @03:32AM (#15583554)
Password itself is an exception, I agree with you since you don't need the plain value at all, you can get away with comparing hashes. But how about CC data?
Re:Can You Afford It? Real-World Web Performance Budgets by setr on Monday October 30, 2017 @12:12PM (#15586139)
Couldn't you do the same? Hash-spaces are segregated by zip codes (hash(zip) is the key to buckets) and then hash the credit card and cvv; compare to verify

Store last 4 digits of cc and mastercard vs visa to provide the "is this the correct card?" form

Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Monday October 30, 2017 @02:28PM (#15587595)
I'm not sure you can. If a site asks you for CC and CVV data it should already be PCI compliant, say a payment processor. Don't they need the plain text CC and CVV to be able to bill it, if it's a first time user? How can the client send a hash, compare it to what?

I'm really curious about how you see this working, I can't understand how you can forever obfuscate your CC info. I assume at some point the server needs your plain data.

Re:Can You Afford It? Real-World Web Performance Budgets by setr on Monday October 30, 2017 @04:59PM (#15588833)
I've personally never worked with payment processors, but I don't see why your intermediate servers would need to have it plaintext

To the payment processor, they'll always have the cc/cvv info, or rather, the hash of it, to verify with. If they don't have it, then I imagine the user doesn't have a valid cc. (How can you have a VISA cc that visa doesn't know about? If its a valid cc, eventually we have to hit someone who knows it...)

For creation of the CC, its entirely done offline atm isn't it? And since its basically just a shared secret, you could do the whole diffie helman physically.. but anyways

So then on your side, as some kind of store, it should be the same as passwords. The payment processor tells you the hash function to use, and you use it client side, and the processor verifies.

Alternatively, you send the user to the someone else (ie redirect to paypal), who does the same thing.

It doesn't seem at all necessary to me that your cc/cvv actually leaves your machine in plaintext. Of course, they may be sending plaintext for some reason, but I don't see an obvious reason why they should

Re:Can You Afford It? Real-World Web Performance Budgets by encoderer on Friday October 27, 2017 @10:33PM (#15573690)
Multi page flows are fine for many data entry style apps which covers a lot of the web.

But for more nuanced software, responsive and rich ui is very important to user uptake.

Examples: Gmail, Facebook, Maps, Slack, SoundCloud, every autocomplete search box everywhere.

If you accept that parts of the page should be interactive then you need to consider the benefit of an isomorphic approach to eliminate code duplication. Usually it's not just a single interactive component.

Re:Can You Afford It? Real-World Web Performance Budgets by Retric on Friday October 27, 2017 @10:50PM (#15573738)
You can do all of that with very lightweight JavaScript though. 10+ years ago I did autocomplete using a few carefully crafted lines of code and the page still renders just fine.

The problem is JS frameworks make development easier but have high real world costs that are often ignored.

Re:Can You Afford It? Real-World Web Performance Budgets by andrewstuart2 on Friday October 27, 2017 @11:33PM (#15573863)
Your second sentence describes engineering trade-offs. The simplest engineering solution to a canyon is to walk around it. The most practical or productive solution over the long run is a different question entirely from the simplest or easiest to implement.
Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Saturday October 28, 2017 @07:29AM (#15574779)
Yup, those are engineering trade-offs. Making your life a little easier by causing users a disproportionate amount of resource waste, frustration and security issues is just shitty engineering. Even though the business types may like it, because externalities are good for profit.
Re:Can You Afford It? Real-World Web Performance Budgets by Retric on Saturday October 28, 2017 @07:08AM (#15574721)
Frameworks are simpler to implement and maintain, that does not make them better for users.
Re:Can You Afford It? Real-World Web Performance Budgets by mmcnl on Saturday October 28, 2017 @04:57AM (#15574492)
Are JS frameworks really easier than your good ol' fully server-side rendered websites? I doubt that. There are costs for everything, both for using and _not_ using JS. It's silly to think that only using JS adds a cost and nothing else. That's just tunnel vision.
Re:Can You Afford It? Real-World Web Performance Budgets by ozim on Saturday October 28, 2017 @04:26AM (#15574434)
"I did autocomplete using a few carefully crafted lines of code"

Now take 10 developers to reuse that autocomplete in the same project in 10 different places. I bet those carefully crafted lines become 100 little monsters, one without eye other with 3 legs.

Not that they have to be stupid, it is just they think differently.

Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Saturday October 28, 2017 @07:31AM (#15574789)
If they were really carefully crafted, then they likely can be carefully repackaged into a solution that could be included in those 10 different places with zero - or close to zero - runtime overhead on the code sharing mechanism.

But it takes actual thinking - and care - to do that. Something that seems to be in short supply with the current web trends.

Re:Can You Afford It? Real-World Web Performance Budgets by Retric on Saturday October 28, 2017 @07:10AM (#15574725)
Users don't care about development. Sure, for us frameworks are great, for them the trade offs look far worse.
Re:Can You Afford It? Real-World Web Performance Budgets by falcolas on Saturday October 28, 2017 @10:22AM (#15575214)
Gmail started out as a multi-page flow, and it worked perfectly fine. Page loads were quick because there wasn't several MB of JS to be interpreted with every page load, just some HTML and CSS.
Re:Can You Afford It? Real-World Web Performance Budgets by kevincennis on Saturday October 28, 2017 @06:50AM (#15574686)
It’s all about how and where you use it.

Imagine a world without AJAX. This is obviously an opinion, but it would be super annoying if every button I clicked sent a raw POST to the server and refreshed the page.

Do news sites need to be rendered client-side with React + Redux + React Router + all the Babel polyfill garbage? No, I don’t think they do.

But some sites are definitely better in my mind for being SPAs.

The problem is that people pick technology that they like or are familiar with instead of working backwards from the ideal user experience. What we should be doing is picking the minimal set of technology that achieves the UX goals of a project. Instead, you have people loading 200kB of dependencies to render pages with a level of interactivity that could be achieved with 30 lines of vanilla JS. Oh, and then Google, FB, Twitter, and Optimizely tracking scripts.

Re:Can You Afford It? Real-World Web Performance Budgets by adambyrtek on Saturday October 28, 2017 @08:08AM (#15574882)
One important and more subtle advantage of SPAs is that they enforce a clean architectural separation of concerns between the untrusted view layer and the backend API. This decoupling allows the frontend team to iterate quickly on user experience and run experiments without affecting the underlying business logic. This also makes it easier to build alternative interfaces (e.g. mobile apps) that share the same API. Of course these benefits matter only when building more complex applications (not simple content sites).
Re:Can You Afford It? Real-World Web Performance Budgets by mratzloff on Saturday October 28, 2017 @08:51AM (#15574986)
> Imagine a world without AJAX.

This is my favorite HN quote of the month.

Re:Can You Afford It? Real-World Web Performance Budgets by falcolas on Saturday October 28, 2017 @10:20AM (#15575211)
I remember gmail before it used AJAX. In many ways, I miss that interface - it just worked. Sure, I didn't get real time email notifications, but come on, it's email. Sure, there were a lot of page refreshes, but they were super quick since there wasn't several MB of scripts being parsed and run with each load. Just some HTML with a few JS interactions.

They even still offer that interface - check it out. It works remarkably well (and quickly) to this day.

Re:Can You Afford It? Real-World Web Performance Budgets by andrewstuart2 on Friday October 27, 2017 @09:54PM (#15573584)
Good single-page app development is just as clean (I've done both), and will be faster over the long term, and scales out better. It keeps all the components cacheable and DRY. The benefits are all about data locality. If your code and data are cached on the client, then the only the minimal subset that has changed needs to be invalidated and updated. If it's only data that has changed, that's all that's retrieved. If it's only code, same goes here. For old-school MVC, if a single character has changed, the whole page is invalidated and must be re-rendered.

The tangible benefits when done right (there's lots of crappy code in every language and system) are greatly reduced user-perceived latency (the system reacts immediately, indicating that something is currently being updated, etc).

Re:Can You Afford It? Real-World Web Performance Budgets by ehnto on Friday October 27, 2017 @10:41PM (#15573718)
It's not a thing of the past. The majority of websites still use this capable and pragmatic approach.

I haven't got any information to support it, but I suspect it was mostly cargo culting from big vendors with big platforms that has made JS Single Page App style sites seem ubiquitous, because everyone in the spotlight is talking about the cool stuff they are doing with it. But in reality they still make up a minority of the web.

Re:Can You Afford It? Real-World Web Performance Budgets by systematical on Friday October 27, 2017 @09:52PM (#15573577)
I prefer the "classic" MVC design approach. It may not be flashy and some may turn their noses for not being hip, but its easy to develop, test, and scale. I certainly use JavaScript, but I use it when it adds to the workflow of the application.
Re:Can You Afford It? Real-World Web Performance Budgets by blattimwind on Saturday October 28, 2017 @04:48AM (#15574480)
> They said that users really wanted native desktop like seamless change pages.

This perhaps roots in the behaviour of browsers ten and more years past. Back in the day, you'd often get a "flash of white" during page loads. Today, not any more. A full-reload and a "seven million lines of JS client-side renderer" application are virtually indistinguishable. Chances are that the "full-reload" app is faster.

Re:Can You Afford It? Real-World Web Performance Budgets by jrobn on Saturday October 28, 2017 @10:33AM (#15575247)
I think today the web is trying to be two things. 1) classic text documents with links to other text documents. 2) a cross-platform runtime for desktop class apps.

Over time 2) has been increasigly shoe-horned into limitations of 1) and its all a giant cluster fuck now. Leave HTML to linked documents and give us an efficient runtime that we can plug into to deliver desktop class apps written in whatever language we want that works with a standardized runtime and UI language shipped built-in with every browser.

Why the hell cant we build web UIs With a standardized UI markup (not HTML), wire it with whatever lanaguage our company uses, and compile it down to WebAssembly and ship it to clients browsers? Instead we have to write these monstrosities in shitty JavaScript with virtual doms, and hacks everywhere. Madness!

Re:Can You Afford It? Real-World Web Performance Budgets by krapp on Saturday October 28, 2017 @10:51AM (#15575300)
>Why the hell cant we build web UIs like we do desktop apps, wire it with whatever lanaguage our company uses, and compile it down to WebAssembly and ship it to clients browsers? Instead we have to write these monstrosities in shitty JavaScript with virtual doms, and hacks everywhere. Madness!

We can, but probably not now, because WebAssembly isn't quite ready yet. It still lacks garbage collection and efficient DOM access, and the specs aren't even finalized. There are already experimental targets for a few languages like Rust[0] and Lua[1], and WASM targets C/C++ out of the box.

Eventually, you'll probably be able to import arbitrary languages and environments with a few HTML tags, similar to Javascript today, or whatever the Webassembly version of a package/dependency/VM manager turns out to be, then compile and run any application ever made in the browser.

[0]https://news.ycombinator.com/item?id=12619017

[1]https://news.ycombinator.com/item?id=13899829

Re:Can You Afford It? Real-World Web Performance Budgets by amelius on Saturday October 28, 2017 @11:10AM (#15575366)
And then there are media companies that try to shoe-horn 1) into 2) because it gives them more control over the user and allows them to track the user and serve them ads.

If only there was a way to collectively punish this type of behavior.

Re:Can You Afford It? Real-World Web Performance Budgets by kakarot on Saturday October 28, 2017 @12:08PM (#15575566)
Like ad blockers and informed browsing habits?
Re:Can You Afford It? Real-World Web Performance Budgets by tjoff on Saturday October 28, 2017 @12:47PM (#15575701)
No, not that. Because that has not worked at all and I see no reason for why it should start working tomorrow.
Re:Can You Afford It? Real-World Web Performance Budgets by sliverstorm on Friday October 27, 2017 @10:23PM (#15573649)
It's probably predicated on a lot of other assumptions. Full refresh might be really annoying if your site is slow and bandwidth heavy. But, for example, squirrelmail is so fast I don't notice the full refreshes.
Re:Can You Afford It? Real-World Web Performance Budgets by liveoneggs on Saturday October 28, 2017 @06:56AM (#15574696)
people want (in ecommerce sites, news sites, actual websites, etc): working back buttons, regular scrolling, open-in-new-tab that works, elements that don't move around, obvious and not-hidden navigation, and also tons of gimmicky/flashy crap.

people want (in desktop replacement spa's where they spend hours and hours): app-appropriate usages of keyboard nav; background tasks with status windows, working back buttons that don't stop the music stream; links that work like links & app-clickables that work like buttons; refresh buttons that refresh (via a page reload) their current full state, but working.

Re:Can You Afford It? Real-World Web Performance Budgets by christophilus on Saturday October 28, 2017 @11:13AM (#15575374)
For me, this sums it up [0]. I prefer HN to Redit because it's snappy. But every site I've ever worked on that didn't start off with a good front-end framework wound up being a huge mess on the front-end. The front end generally becomes more and more complex even for simple sites.

"Can we add discussions to this page?" "Great! Now, can they be live-updating?" "Great! Now, can we have a nice little notification counter?" "Great! Now can it be collaboratively edited?"

Eventually, the front end becomes a monstrosity.

When starting out, if you just plan for a complex front end, and choose a well-structured framework, your life as a developer will be much less painful. Yes. It's overkill for a blog. But who among us is really building a simple blog? We're building applications that happen to run in the browser.

[0] https://hackernoon.com/why-does-this-site-require-javascript...

Re:Can You Afford It? Real-World Web Performance Budgets by herbst on Friday October 27, 2017 @10:26PM (#15573668)
MVC + Turbolinks. I still barely use any JS except frontend libs for fancy utils.
Re:Can You Afford It? Real-World Web Performance Budgets by mratzloff on Saturday October 28, 2017 @08:44AM (#15574966)
> Do we need all this JS?

The answer to this question is always no.

Re:Can You Afford It? Real-World Web Performance Budgets by nickjj on Saturday October 28, 2017 @09:18AM (#15575039)
I wrote about this exact topic last week at https://nickjanetakis.com/blog/server-side-templates-vs-rest....

The TL;DR is, the classic web development model still works amazingly well today and you can get real-time aspects by sprinkling in Javascript where needed.

Re:Can You Afford It? Real-World Web Performance Budgets by samsonradu on Saturday October 28, 2017 @02:45AM (#15574239)
Regarding full refreshes, I was thinking the other day why do browser vendors not implement them more graciously, as in Pjax style, but a clean reload. The problem with Pjax is that it still keeps state around, when I want to simply remove all state (setTimeouts, setIntervals, websocket connections, events binded to $window etc.)
Re:Can You Afford It? Real-World Web Performance Budgets by jrs95 on Saturday October 28, 2017 @12:40AM (#15574009)
Even the full page loads aren't necessary with Turbolinks or PJAX. If I had a choice, thats definitely what I'd be using for what I'm working on now at an ecommerce company. But the boss insists on microservices, and the once the advantages that come with a monolith are gone the SPA is just a better approach imo
Re:Can You Afford It? Real-World Web Performance Budgets by sanderjd on Saturday October 28, 2017 @01:16AM (#15574072)
Correct me if I'm wrong, but don't Turbolinks and PJAX work through JS as well?
Re:Can You Afford It? Real-World Web Performance Budgets by jrs95 on Saturday October 28, 2017 @05:03PM (#15576759)
Yes, but way less. Turbolinks in particular basically just requires you to add the library, which is very lightweight, and then you get page changes without the bad visuals of the whole screen flashing white, and it's not too difficult to keep it fast too.
Re:Can You Afford It? Real-World Web Performance Budgets by rictic on Friday October 27, 2017 @10:47PM (#15573729)
Most sites can do with very little JS. Many do well with just a bit, like hacker news, which uses JS for little stuff like voting.

Appier sites, like video, music, games, maps, etc are gonna need a lot more client-side logic to be pleasant to use.

Re:Can You Afford It? Real-World Web Performance Budgets by mac01021 on Saturday October 28, 2017 @06:45AM (#15574672)
I'm no fan of “modern js-based design”, but I can pay for a lot less server if I can get the client to do all the rendering for me.
Re:Can You Afford It? Real-World Web Performance Budgets by TeMPOraL on Saturday October 28, 2017 @07:43AM (#15574815)
Yup.

But the thing to consider is - a lot of things can be pre-rendered and cached. Your server can render it once and serve to many clients. With client-side rendering, each client is rendering the same thing for themselves, possibly slower than on your server because JS is not exactly the sharpest tool in the shed. So you've saved yourself $N in compute but externalized $N * number of users * relative JS inefficiency. This is not a nice thing to do.

Re:Can You Afford It? Real-World Web Performance Budgets by albertgoeswoof on Saturday October 28, 2017 @06:50AM (#15574689)
I would wager that most people who say this have never actually calculated the cost of server side rendering vs bandwidth costs + users dropping off the site
Re:Can You Afford It? Real-World Web Performance Budgets by naasking on Saturday October 28, 2017 @01:18PM (#15575860)
> I know we switched because front end experts told us that users found the full refreshes annoying. They said that users really wanted native desktop like seamless change pages. Never did I see proof of these claimed.

Even so, you can have that experience with server-side rendering and simpler client-side updating.

Re:Can You Afford It? Real-World Web Performance Budgets by tomaskafka on Saturday October 28, 2017 @02:53PM (#15576258)
This. Several old-style 'server side rendered' pages I made seem superfast with https://github.com/turbolinks/turbolinks .
Re:Can You Afford It? Real-World Web Performance Budgets by amelius on Saturday October 28, 2017 @06:11AM (#15574608)
How would you implement collaborative editing, where users can see each other type instantly?
Re:Can You Afford It? Real-World Web Performance Budgets by scientistem on Friday October 27, 2017 @09:27PM (#15573497)
I think there is (limited) semantic value to single page forms. They also encourage api first design. Is this always worth it? Certainly not. But it does have value.
Re:Can You Afford It? Real-World Web Performance Budgets by cabaalis on Friday October 27, 2017 @09:34PM (#15573521)
I think the problem is in all the data-binding of JSON responses to the front end. I don't care what anyone says, it's slow.
Re:Can You Afford It? Real-World Web Performance Budgets by osrec on Friday October 27, 2017 @10:06PM (#15573608)
Slow in what sense? I mean, for almost all actual use cases, it seems to be quick enough when done right.
Re:Can You Afford It? Real-World Web Performance Budgets by andrewstuart2 on Friday October 27, 2017 @09:50PM (#15573572)
If you don't care what anyone says, then I guess there's no point in presenting data.