News for hackers. Stuff that matters.
Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @12:43PM (#16053571)
Server-side rendering means you get a quick first load. Client-side rendering means subsequent navigations are quick, because there's less data to transfer (maybe a little bit of JSON, maybe nothing at all). Going back to the server for 100kb of HTML and reloading the entire page, as opposed to fetching 10kb of JSON and instantly updating it in place, is a very 2002 way of doing things!
Re:Show HN: Sapper.js – towards a better web app framework by RobertRoberts on Tuesday January 02, 2018 @12:57PM (#16053691)
>...because there's less data to transfer...

The problem is that just the theory, reality if often times different.

>Going back to the server for 100kb of HTML and reloading the entire page...

This implies that 1) you don't go "back to the server" to load your bit of JSON. and 2) the JSON loaded doesn't require any extra templates, images or more JSON to be loaded. See the problem? It's all assumptions.

Another thing, what about browser caching? I can see how the next page loads _only_ the html, as all the js, css and images were loaded already. I think you are falling for the exaggerated speed benefits from making a website with a JS framework.

To be clear, I am talking about a web page, an HTML document, static content. Maybe that's where the confusion happens in discussions like this. (I said "sites", not "webapps" in my original comment)

A history lesson, we did this with Flash years ago (no more page refreshes!), and everyone ultimately learned to hate it. Just because the flashy crap is spread over the entire "webapp/site" to every button, mouseover and click doesn't mean it's useful or better. (I think many devs think they need to build basic site features with big frameworks just to "stay modern".) Look at Youtube, it's slower now that they implemented their "webapp" experience, but the page doesn't "refresh", so that is somehow better... (is youtube really a webapp? Or a bunch of pages with videos on them?)

Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @01:02PM (#16053736)
Ultimately, the proof is in the pudding. Which is faster, when you start navigating around?

* https://news.ycombinator.com/item?id=16052558

* https://hn.svelte.technology/item/16052558

Bear in mind that HN itself has a huge advantage over HN clones, yet — for me at least, sitting here — the Sapper version is significantly snappier.

Re:Show HN: Sapper.js – towards a better web app framework by RobertRoberts on Tuesday January 02, 2018 @01:58PM (#16054342)
I tried this on my phone. (Android/Firefox) And I found that it's about .5 second to navigate between pages on hn.svelte.technology And about 1.5-2 seconds with the news.ycombinator.com, on average. Sometimes the straight page load was just as fast (.5 second) and sometimes it sat there while 3-5 seconds.

Yes, the svelte is generally faster on my phone as well. (I am not sure I see the need for a framework for this specific feature though, it's just a js tabs sort of interface. It doesn't seem like a good argument piece for or against this framework)

I did get a possible error, the pages didn't match up after a while. Is the svelte data was being cached in a way that can't refresh properly? I can't debug this as a normal user, does hitting refresh do anything to reload the site content on the svelte site?

Try this, open both sites in different tabs, and navigate around on them a few times, and after awhile, the news.ycombinator will show new content, and the other one will be different. (I am guessing older content, server cache issue? I didn't compare carefully, maybe they started off different and I didn't notice)

Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @03:23PM (#16055234)
Possibly a misbehaving service worker serving stale content! I can never configure those right first time.
Re:Show HN: Sapper.js – towards a better web app framework by dgreensp on Tuesday January 02, 2018 @01:34PM (#16054074)
Hi Rich. On my iPhone, I get a 3-second delay between when I “swipe to go back” and when the page is usable/scrollable on the Sapper HN. When I first went to the site, via the link above, the top nav links did not seem to work reliably, and it may have been the same 3-second delay, but I’m only getting now when swiping to go back — maybe because the page is being reloaded from the server? It’s still quite a delay, though.
Re:Show HN: Sapper.js – towards a better web app framework by shoover on Tuesday January 02, 2018 @02:12PM (#16054483)
Interesting. I get behavior like that with twitter.com on the iPad. It hangs with a blank white page for a few seconds. I always wondered what kind of client script shenanigans were going with that. Using the back button embedded in the web page does not cause the same delay.
Re:Show HN: Sapper.js – towards a better web app framework by boubiyeah on Tuesday January 02, 2018 @03:43PM (#16055444)
I get the same behavior on my phone with their new website too. Service worker infancy bugs?
Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @01:45PM (#16054186)
Hi David! That's odd — it sounds like maybe you're interacting with the nav before the client-side app starts, though it's a little hard to tell exactly. Will try and reproduce it here — thanks
Re:Show HN: Sapper.js – towards a better web app framework by dsego on Tuesday January 02, 2018 @02:36PM (#16054759)
Bearing in mind that HN loads content in html tables, which are notoriously slow to render. I am not saying it makes a huge difference, but it could have an impact.
Re:Show HN: Sapper.js – towards a better web app framework by Touche on Tuesday January 02, 2018 @01:14PM (#16053857)
Judging based on the 'load' event they are about the same, or the HN version might be a little bit (<100ms) faster. The Sapper version is faster with the service worker.

So basically the added complexity gives you the same load time when done extremely well (as Sapper is). In terms of bang for your buck, the service worker is biggest improvement. Which you can implement in your server-rendered app.

Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @01:29PM (#16054018)
What about when you start clicking the links in the nav, or opening other stories and profile pages? As far as I can see, the Sapper version blows the original out of the water.
Re:Show HN: Sapper.js – towards a better web app framework by lassejansen on Tuesday January 02, 2018 @03:40PM (#16055405)
The Sapper version is cheating a little. It is preloading the pages on mouseOver events of the links.
Re:Show HN: Sapper.js – towards a better web app framework by DougWebb on Tuesday January 02, 2018 @06:32PM (#16056936)
It's not just cheating a little. Just moving the mouse around the page causes lots of data to be downloaded behind the scenes; you could end up loading every story on HN without ever leaving the Top list. That's not friendly to user's data plans, and it's very far from expected browser behavior.
Re:Show HN: Sapper.js – towards a better web app framework by rich_harris on Tuesday January 02, 2018 @07:25PM (#16057253)
It's configurable. Add rel=prefetch to an <a> element and you'll get that behaviour; don't, and you won't. Since the links are small, mousing over them tends to suggest you intend to click them, but the exact behaviour is subject to refinement over time (this is pre-1.0 software, adjust your expectations accordingly).

Incidentally, 'cheating' is a bit of a silly word to use for a feature designed to improve UX that people spend a lot of time trying to implement (see e.g. http://instantclick.io/)

Re:Show HN: Sapper.js – towards a better web app framework by RobertRoberts on Tuesday January 02, 2018 @01:36PM (#16054090)
Yep, the svelte version here appears faster. I'd have to inspect the network traffic to see what it's doing with the data. But I can see a definite speed advantage in this circumstance. To bad it doesn't work everywhere like this.

How fast would it load if every entry had an image? Maybe then it wouldn't seem so different? (edit: this is from a desktop/Firefox)

Re:Show HN: Sapper.js – towards a better web app framework by chaoticsamuel on Tuesday January 02, 2018 @01:21PM (#16053938)
It's not just the initial page load though (although that's essentially similar speed). Navigate through the site, and you shave off seconds at every next click.
Re:Show HN: Sapper.js – towards a better web app framework by boubiyeah on Tuesday January 02, 2018 @03:41PM (#16055427)
I get what you mean and you are right in a way, but raw performance is not the only thing to consider. Yes, server rendered sites are usually an order of magnitude simpler to code than these JS-rendered solutions, and are often faster, but where JS rendering shines is interactivity and perceived performances: you always know what is going on! loading, sending a text, etc (provided the UX is right) Sprinkling some client-side code on top of server rendered templates is so limitating for everything but the simplest websites!

It's 80% more effort for the 20% last performance/richness points.

it's over, people want/expect these kinds of apps, e.g feels as good as native apps but on the web.

But you're also right some people misuse that kind of technology to a ridiculous extent. Downloading a 3MB angular app just to display a crappy site without any rich interactions is really infuriating but that's just bad engineering and people who make choices based on what's popular, disregarding context.

Re:Show HN: Sapper.js – towards a better web app framework by timr on Tuesday January 02, 2018 @01:00PM (#16053725)
Going back to the server for 100kb of HTML and reloading the entire page, as opposed to fetching 10kb of JSON and instantly updating it in place, is a very 2002 way of doing things!

The difference between streaming 100kb and 10kb is small when compared to the connection latency itself. Even on a low-end LTE connection (5mbps), 100kb is 20ms, whereas the latency of a cross-country (US) transit is realistically ~50-100ms. The difference decreases further when you enable server-side compression and start doing fragment rendering, which tends to remove the penalty for HTML payloads.

The argument for react-like technologies is not connection latency, but rather, the hope that you can avoid synchronous connections in the first place by moving your view logic client-side. And truthfully, few client-side apps are written in a way that would minimize payloads anyway. Most people are doing it because they hate working with the DOM and AJAX and server-side frameworks in a mishmash of web technologies, and perceive these client-side frameworks as easier.

Re:Show HN: Sapper.js – towards a better web app framework by GordonS on Tuesday January 02, 2018 @01:16PM (#16053881)
There is also browser caching. So subsequent page loads may not require any new scripts or stylesheets to be loaded, for example, so you're only loading some GZIPped HTML.
Re:Show HN: Sapper.js – towards a better web app framework by noxecanexx on Tuesday January 02, 2018 @03:52PM (#16055499)
You couldn't have said it any better.
Re:Show HN: Sapper.js – towards a better web app framework by dsego on Tuesday January 02, 2018 @02:40PM (#16054810)
If we replaced JSON with something less "chatty", would that propel us to 2022?
Re:Show HN: Sapper.js – towards a better web app framework by al2o3cr on Tuesday January 02, 2018 @12:58PM (#16053697)

    is a very 2002 way of doing things
Despite sharing a common three-letter prefix, "fast" and "fashionable" are frequently uncorrelated qualities.
Re:Show HN: Sapper.js – towards a better web app framework by vitro on Wednesday January 03, 2018 @07:02AM (#16060278)
You know, we may be to specialized to see that normal users that are in majority do not care. Of course you may argue that page load and responsiveness is important in regard to the conversion metrics, be it so, but imagine some average non IT person. Your mother in her seventies. A high school friend. Your auntie. Do you think they care what technology is used? Certainly not. I've seen sites that you would label ugly and from 2000's, but they just work, users can use them easily. And I have seen a rewrite of such old site to modern js framework and it was a disaster, owner was sued by users of the site as they were missing profits because the site was slow and cumbersome.

I think the question is, who do you write the site for, for others or to satisfy your ego and show off?

Re:Show HN: Sapper.js – towards a better web app framework by goatlover on Tuesday January 02, 2018 @01:02PM (#16053742)
How long does it take going back to the server and loading 100kb of HTML these days?