Philosophy
Qwik's goal is to have applications that have a fast startup. We believe that fast startup has these benefits:
- Users use a fast startup time as a proxy for the site quality.
- The faster a site can become interactive, the lower the bounce rate and higher the conversions (and hence profit).
During site startup, the browser has to do a lot of things that negatively impact startup performance:
- Browser has to render the initial HTML.
- Browser has to execute your application (rehydration).
- Browser has to execute third-party code.
Because JavaScript is single-threaded, all of the above tasks compete for a single CPU core. Your site startup performance is directly proportional to how much JavaScript the browser needs to execute to get the site interactive.
Core tenant
Qwik is designed around this core tenant:
Delay execution of JavaScript as much as possible.
Qwik applications startup fast because there is a minimal amount of JavaScript code to execute. (At its simplest, a Qwik application only needs about 1KB of JavaScript to become interactive.)
By aggressively delaying the application download and execution, Qwik can provide near-instant startup performance that current generations of web frameworks can't match.
Qwik is fast not because it uses clever algorithms but because it is designed in a way where most of the JavaScript never needs to be downloaded or executed. Its speed comes from not doing things (such as hydration) that other frameworks have to do.
Resumability & Serialization
Resumability is discussed in detail here. Resumability allows Qwik applications to continue execution where the server left off. All frameworks need to keep track of internal data structures about the application's state. The current generation of frameworks does not preserve this information from the server to browser transition. As a result, the framework's data structures need to be rebuilt in the browser. The rebuilding of data structures and attaching of listeners is called hydration.
Qwik serializes listeners, internal data structures, and application state into the HTML on server browser handoff. Because all of the information is serialized in HTML, the client can just resume execution where the server left of.
Hydration forces the current generation of frameworks to download JavaScript that is associated with the current set of components on the page to make them interactive. The more complex the HTML and the more complex the components, the more JavaScript needs to be downloaded and executed. Qwik does not need hydration, and therefore, non of the JavaScript needs to be eagerly downloaded to make the application interactive.