5 ms·
I don't know that I will ever be happy with lazy loaded UIs over a more traditional "Deliver everything first, update later" approach. Hopefully Suspense is a s
by ehnto 7y ago
I don't know that I will ever be happy with lazy loaded UIs over a more traditional "Deliver everything first, update later" approach. Hopefully Suspense is a step to solving the problem.
I live in Australia, so there's a perceptible ~300ms delay for every action in react-like loaded later UIs that aren't hosted in Australia, which is most of the tools that I use. They feel clunky and broken, and the amount of times you miss-click because something pops in suddenly and moves the button you wanted down the page. I don't think it's the UI they think they've built.
I don't think it will ever be good enough to throw 20 requests and wait for everything to update, bounce the page around and at long last be intractable. I would rather receive a 2mb page right now, than a 200kb page that slowly grows to a 2mb page over the course of 20 components individually loading themselves.
- badfrog 7y ago> a 2mb page right now, than a 200kb page that slowly grows to a 2mb page over the course of 20 components individually loading themselves. Isn't the point that the 200kb is static code that can be served immediately, while the rest can't? Regardless of whether the remaining 1.8mb is built on the server or client, it still isn't available "right now"
- picardo 7y agoI think what he is saying is since there is a network delay of 300ms for every request, it's better for him to make a single request for a large file than to have to make 10 requests for 200k files and wait 300ms * 10.
- treve 7y agoIf every requests adds this fixed latency, it would be much better to try and parallelize the requests vs bundling everything.
- picardo 7y agoTrue, but these requests cannot be made simultaneously. The code is loaded only when the UI needs it.
- treve 7y agoIf the files can be combined, the requests can be made simultaneously
- ehnto 7y agoYou're right, and HTTP/2 was supposed to be a major boon here, but the problem is actually that the UI itself only loads these things once they've been rendered by the framework which is often after another component has loaded them, and even if they can be ran in parallel the response times can still vary, causing the UI jiggle you often see. This isn't really a problem unique to high latency either, if you have a patchy connection in transit or for some other reason, the UI will suffer.
- badfrog 7y ago> but the problem is actually that the UI itself only loads these things once they've been rendered by the framework which is often after another component has loaded them That just sounds like bad front end coding. A good framework used properly would not have that issue.
- honopu 7y agoIn webpack you can define which components are in which chunk, so you could organize them that way. I don't, but I know it exists.
- k__ 7y agoIf you have high bandwidth and low latency, bigger packages can lead to better user experience.
- ehnto 7y agoMost of the time it is though. I can understand if you have interacted with a component and now it needs to load new data. But on first page load, all the data you intend to show them you should be able to fetch and send with the initial request.
- badfrog 7y ago> all the data you intend to show them you should be able to fetch and send with the initial request. Sure, but if it requires data from five different services and significant compute time, the initial request is going to be very slow. Users are more likely to bail out if they see nothing for a few seconds than if they immediately see a loading screen that lasts for a few seconds.
- ehnto 7y agoIt's true, there are definitely use cases for lazy-loading UI. I would wager the majority of the time lazy-loaded UI is only present because the engineering team wanted to use new tools and not because there was a requirement to ease long compute calls though, but I'm speculating.
- onion2k 7y agoI don't know that I will ever be happy with lazy loaded UIs over a more traditional "Deliver everything first, update later" approach. There's a nice middle ground. In the app I work on very little is included at start up. It's literally just the components for the first screen you see. Then it pre-loads more components whenever the browser is idle based on what the user is likely to need. If the user does something that needs a component that isn't available yet it lazy loads it as usual. If you only use lazy loading the user has to do something that needs a component and then wait until it's available. The strategy I use means there's an additional phase that utilises the time when the browser is idle, so it's much more likely everything is available before it's needed. It works well.
- hanoz 7y ago> and at long last be intractable Freudian slip? Sounds about right though. The usability of huge portions of the web has deteriorated markedly in the last few years due to the over use of client-side frameworks.
- ehnto 7y agoHa! Indeed, I meant interactable, although it seems that's not considered a word yet. I'm sure it will be soon enough.
- arkh 7y ago> the amount of times you miss-click because something pops in suddenly and moves the button you wanted down the page Browsers should have an option to let you send click events to what was under the mouse 200ms before it was registered. But it would be a colossal PITA to implement.
- jakemoshenko 7y agoI would honestly just prefer to throw the click away if the thing it's going to send it to wasn't there when my brain decided to click.
- some1else 7y ago`prefer-reduced-motion` could skip handling events on elements that moved recently.
- anewguy9000 7y agothe misclick because of slow loading/moving components drives me batshit crazy. esp when the click loads a new page: need to go back, wait.. safe to click it now? oops nope!! repeat
- revskill 7y agoIs is solvable if you directly use import Component from 'component' instead of lazy loading it ?
- JMTQp8lwXL 7y agoIt's unclear to me what the alternative is. Would you prefer less interactive, but server-side rendered pages? Latency is latency, and if the closest node to you is somewhere in US West 2, the problem isn't react, the problem is the application is widely distributed enough for you to get acceptable response times. If you do server-side rendered pages, you still have to make the round-trip to get the next full HTML page. Switching to Vue or Svelte or JSPs isn't changing that.
- xixixao 7y agoThe answer is aggressive prefetching. How much to prefetch depends on each UI structure and the weight of the prefetched components.
- RussianCow 7y agoNot only this, but proper loading states for anything that is happening asynchronously. I am so sick of web apps that show absolutely no sign that a request is in progress.
- strbean 7y agoThat is what "Suspense for Data Fetching" is going to help with. It is already perfectly possible to handle data fetching nicely, it just isn't incredibly easy. When Suspense for Data Fetching goes stable, it will be trivial to do right.
- JMTQp8lwXL 7y agoThat would help movement between pages in a single-page application, though cold boot times will still be less than desirable. If I immediately go to the SPA, and then navigate from page A to page B and the prefetching hasn't completed yet, it can be a jarring experience. I've occasionally clicked on the wrong thing in a UI because the website repainted as I clicked, causing the DOM to shuffle around considerably. New Reddit seems to be a good example of this problem today.
- ehnto 7y ago
- deleted 7y ago[deleted]