Building a Web-App: The Easy Path and the Performant Path. Why Are They Not the Same?

Rate this content
Bookmark

We use frameworks to make building our applications easier. Yet as the application scales, its performance suffers. There is no one thing, but rather a death by thousand cuts. Developers are under pressure, and they often choose the easy and quick path to deliver a feature rather than the performant path. The performant path is usually more work. So let's look at these two paths and imagine a world where the performant path is the quick and easy path.

FAQ

Builder.io is a headless visual CMS system that is not hosted. It allows users to npm install it inside their applications, drag and drop components, and achieve visual editing capabilities. It facilitates the registration of custom components, enabling marketing personnel to modify landing pages without needing engineering assistance.

Hydration is a process used in web development where a server-side rendered page is made interactive. Initially, the page is sent as static HTML from the server, appearing quickly but without interactivity. JavaScript is then downloaded and executed to bind event listeners and make the DOM interactive, a process known as 'reconciliation' or 'hydration.'

Partytown is a technology designed to enhance website performance by relocating third-party JavaScript code to web workers. This approach minimizes the main thread's workload, leading to faster interactions and improved user experience on the website.

Mitosis in web development refers to a process that allows developers to write code once and generate canonical code for multiple frameworks such as React, Angular, Vue, and Svelte. This helps in maintaining a single codebase while supporting various frontend technologies.

Resumability is an alternative approach to web application loading where the initial HTML contains all necessary information, including where event listeners are located. This allows for immediate interaction upon page visibility, without waiting for JavaScript to download, thus speeding up interactivity and reducing JavaScript size by eliminating duplicate data.

Quik optimizes web application performance by introducing concepts like signal and code extraction. These concepts allow the compiler to perform optimizations that ensure constant startup performance regardless of application size, support lazy loading and execution, and minimize the JavaScript needed for initial interactivity.

In Quik's architecture, the service worker pre-fetches necessary code segments as the user navigates the application, storing them in cache. This ensures that when interactive elements are required, they can be retrieved quickly from the cache, reducing load times and enhancing the user experience on slower or unreliable networks.

Miško Hevery
Miško Hevery
31 min
01 Jun, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Misko Havry introduces himself and discusses the impact of JavaScript on performance. The concepts of reconciliation, hydration, and resumability are explored, along with the importance of clean code and compiler optimization. The Talk includes demos of application components and showcases the power of code extraction. The QUIC framework is highlighted for its ability to optimize code loading and prioritize interactions. The service worker is used to selectively download components for improved performance. SEO and debugging in QUIC are also discussed, along with comparisons to other frameworks.

1. Introduction to Misko Havry and Performance

Short description:

Let's get started with a joke about how functions break up. I'm Misko Havry, the creator of AngularJS and Quik. We also have Partytown and mitosis. Let's talk about performance and how JavaScript can impact it.

So, with that, let's get started. Happy Android. Thanks, guys. Thank you. I think we also need to give applause to our emcees. I could not do their job. So I'm going to start with a joke, because I love dead jokes when I'm a dad. So how do functions break up? They stop calling each other. And it's actually a relevant joke. Because we're going to show you how the functions break up in this presentation.

So hi, I'm Misko Havry. You might know me, because I've done this thing called AngularJS, and now I'm working on this thing called Quik, and hopefully you've heard of builder.io. It's a headless visual CMS system. What it is, is Imagine Wix, but not hosted. Instead, npm install inside of your application. You drag it in and then you get visual editing. And you can also, because it's your application, you can register your own components with it and have your marketing people go wild. And they don't have to bug you, the engineer, about changing anything on their landing pages.

Now, we do other things too. We do Quik. But we also have this thing called Partytown, which moves third party code into web workers. And we do mitosis, which allows you to write your code once. And we generate canonical code for React, Angular, Vue, Svelte, and anything else that you can possibly imagine. But let's talk about performance. So this is kind of a typical randomly selected set of websites from the web. And notice, they're all kind of green, maybe some yellow. It really isn't looking that good. Why is that? You know, if you build a simple hello world app and you push it somewhere, the performance is great, but once you put real applications, you know, real traffic behind it, the performance doesn't go so well. And there's a lot of different reasons for it, but one thing I'm really going to try to convince you of is that it is JavaScript. And basically, too much of it.

2. JavaScript and Hydration

Short description:

This is a chart from HTTP archive showing the increasing amount of JavaScript being sent to browsers over time. Users expect complex applications, which require JavaScript. The more JavaScript shipped, the lower the light house score. Hydration is a workaround that creates a problem. Previously, applications would boot by sending empty HTML and loading JavaScript. To eliminate the white screen, server-side prerendering was introduced, but it lacks interactivity until the JavaScript is downloaded and executed.

And if you look at it, this is a chart from HTTP archive. This is the amount of JavaScript that we have been sending to our browsers over time. And as you can see, that's just going up, up, up. And I'm going to make a bet that in the future, there's even going to be even more JavaScript. And it totally make sense because our users experience expect complicated rich applications. And you cannot deliver complex applications without JavaScript. And so we need JavaScript.

You know, there isn't the world where we stop shipping JavaScript or is there? So this is another interesting graph from HTTP archive. I've selected a few frameworks here. This is not important. What I want to show you here is that the median score that the website gets and the amount of JavaScript that's being shipped are essentially inverse of each other, right? The more JavaScript you ship, the lower your light house score. And the less JavaScript you ship, the better your light house score. That shouldn't be surprising. This should be like self-evident, right? That the less JavaScript you ship, the better the thing will be. The problem is that the way our applications work is we have this thing called hydration.

And hydration is this interesting workaround we have created and is creating this problem. So let me explain. Back in the day before we had meta frameworks like Next.js, the way the applications would boot is we would send HTML. The HTML would be empty. And into the HTML there would be a script tag that would load JavaScript. JavaScript would execute your application, the application would cause a render and then the render would make a website and now you can interact with the website. But we said, you know what? We really don't like the fact that there is this whitescreen there for several seconds. We really want to get rid of that. So we said, you know what? We know the solution to that. We're just gonna go server-side prerendering. So, we sent now a bigger HTML, notice the HTML got bigger, and now the page isn't white. It's the actual application that you have. But guess what? You cannot click on it. It appears faster which is great but you can't have any interactivity on that page yet. So at this point we download the JavaScript, execute the application.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

A Guide to React Rendering Behavior
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
Top Content
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
React Compiler - Understanding Idiomatic React (React Forget)
React Advanced Conference 2023React Advanced Conference 2023
33 min
React Compiler - Understanding Idiomatic React (React Forget)
Top Content
React provides a contract to developers- uphold certain rules, and React can efficiently and correctly update the UI. In this talk we'll explore these rules in depth, understanding the reasoning behind them and how they unlock new directions such as automatic memoization. 
Speeding Up Your React App With Less JavaScript
React Summit 2023React Summit 2023
32 min
Speeding Up Your React App With Less JavaScript
Top Content
Too much JavaScript is getting you down? New frameworks promising no JavaScript look interesting, but you have an existing React application to maintain. What if Qwik React is your answer for faster applications startup and better user experience? Qwik React allows you to easily turn your React application into a collection of islands, which can be SSRed and delayed hydrated, and in some instances, hydration skipped altogether. And all of this in an incremental way without a rewrite.
React Concurrency, Explained
React Summit 2023React Summit 2023
23 min
React Concurrency, Explained
Top Content
React 18! Concurrent features! You might’ve already tried the new APIs like useTransition, or you might’ve just heard of them. But do you know how React 18 achieves the performance wins it brings with itself? In this talk, let’s peek under the hood of React 18’s performance features: - How React 18 lowers the time your page stays frozen (aka TBT) - What exactly happens in the main thread when you run useTransition() - What’s the catch with the improvements (there’s no free cake!), and why Vue.js and Preact straight refused to ship anything similar
SolidJS: Why All the Suspense?
JSNation 2023JSNation 2023
28 min
SolidJS: Why All the Suspense?
Top Content
Solid caught the eye of the frontend community by re-popularizing reactive programming with its compelling use of Signals to render without re-renders. We've seen them adopted in the past year in everything from Preact to Angular. Signals offer a powerful set of primitives that ensure that your UI is in sync with your state independent of components. A universal language for the frontend user interface.
But what about Async? How do we manage to orchestrate data loading and mutation, server rendering, and streaming? Ryan Carniato, creator of SolidJS, takes a look at a different primitive. One that is often misunderstood but is as powerful in its use. Join him as he shows what all the Suspense is about.
From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
We all love GraphQL, but it can be daunting to get a server up and running and keep your code organized, maintainable, and testable over the long term. No more! Come watch as I go from an empty directory to a fully fledged GraphQL API in minutes flat. Plus, see how easy it is to use and create directives to clean up your code even more. You're gonna love GraphQL even more once you make things Redwood Easy!

Workshops on related topic

React Performance Debugging Masterclass
React Summit 2023React Summit 2023
170 min
React Performance Debugging Masterclass
Top Content
Featured WorkshopFree
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
React at Scale with Nx
React Summit 2023React Summit 2023
145 min
React at Scale with Nx
Top Content
Featured WorkshopFree
Isaac Mann
Isaac Mann
We're going to be using Nx and some its plugins to accelerate the development of this app.
Some of the things you'll learn:- Generating a pristine Nx workspace- Generating frontend React apps and backend APIs inside your workspace, with pre-configured proxies- Creating shared libs for re-using code- Generating new routed components with all the routes pre-configured by Nx and ready to go- How to organize code in a monorepo- Easily move libs around your folder structure- Creating Storybook stories and e2e Cypress tests for your components
Table of contents: - Lab 1 - Generate an empty workspace- Lab 2 - Generate a React app- Lab 3 - Executors- Lab 3.1 - Migrations- Lab 4 - Generate a component lib- Lab 5 - Generate a utility lib- Lab 6 - Generate a route lib- Lab 7 - Add an Express API- Lab 8 - Displaying a full game in the routed game-detail component- Lab 9 - Generate a type lib that the API and frontend can share- Lab 10 - Generate Storybook stories for the shared ui component- Lab 11 - E2E test the shared component
Building WebApps That Light Up the Internet with QwikCity
JSNation 2023JSNation 2023
170 min
Building WebApps That Light Up the Internet with QwikCity
Featured WorkshopFree
Miško Hevery
Miško Hevery
Building instant-on web applications at scale have been elusive. Real-world sites need tracking, analytics, and complex user interfaces and interactions. We always start with the best intentions but end up with a less-than-ideal site.
QwikCity is a new meta-framework that allows you to build large-scale applications with constant startup-up performance. We will look at how to build a QwikCity application and what makes it unique. The workshop will show you how to set up a QwikCitp project. How routing works with layout. The demo application will fetch data and present it to the user in an editable form. And finally, how one can use authentication. All of the basic parts for any large-scale applications.
Along the way, we will also look at what makes Qwik unique, and how resumability enables constant startup performance no matter the application complexity.
Next.js 13: Data Fetching Strategies
React Day Berlin 2022React Day Berlin 2022
53 min
Next.js 13: Data Fetching Strategies
Top Content
WorkshopFree
Alice De Mauro
Alice De Mauro
- Introduction- Prerequisites for the workshop- Fetching strategies: fundamentals- Fetching strategies – hands-on: fetch API, cache (static VS dynamic), revalidate, suspense (parallel data fetching)- Test your build and serve it on Vercel- Future: Server components VS Client components- Workshop easter egg (unrelated to the topic, calling out accessibility)- Wrapping up
React Performance Debugging
React Advanced Conference 2023React Advanced Conference 2023
148 min
React Performance Debugging
Workshop
Ivan Akulov
Ivan Akulov
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
Master JavaScript Patterns
JSNation 2024JSNation 2024
145 min
Master JavaScript Patterns
Workshop
Adrian Hajdin
Adrian Hajdin
During this workshop, participants will review the essential JavaScript patterns that every developer should know. Through hands-on exercises, real-world examples, and interactive discussions, attendees will deepen their understanding of best practices for organizing code, solving common challenges, and designing scalable architectures. By the end of the workshop, participants will gain newfound confidence in their ability to write high-quality JavaScript code that stands the test of time.
Points Covered:
1. Introduction to JavaScript Patterns2. Foundational Patterns3. Object Creation Patterns4. Behavioral Patterns5. Architectural Patterns6. Hands-On Exercises and Case Studies
How It Will Help Developers:
- Gain a deep understanding of JavaScript patterns and their applications in real-world scenarios- Learn best practices for organizing code, solving common challenges, and designing scalable architectures- Enhance problem-solving skills and code readability- Improve collaboration and communication within development teams- Accelerate career growth and opportunities for advancement in the software industry