These optimizations make Vue more efficient, modular, and easy to use. I will discuss these changes and the impact I believe they’ll have following Vue 3.0’s release.
In their own words, Vue is a “progressive framework for building user applications”. It’s designed to be super flexible with the ability to either incorporate individual Vue libraries into other projects or powering complex projects entirely with Vue.
As of early 2019, we are still in Vue 2.0. While still holding a tiny share of the market in comparison to React and Angular, Vue has been continuously rising in popularity. In my opinion, the release of Vue 3.0 will boost its usage and make it even more of a legitimate alternative to the other major frameworks.
Below is a graph showing the number of job availabilities for each framework. As you can see, VueJS still as a ways to go before coming close to the current industry standards.
In his keynote, Evan You highlighted five key changes coming in Vue 3.0:
Now let’s explore these in depth.
This topic took up a large portion of You’s talk as it has the most technical changes and is clearly one of Vue’s major selling points nowadays.
VueJS is already known for its render speed. In it’s comparison tests, it outperforms other frameworks. However, the number of edge cases and fixes made to the 2.0 code made the Vue team decide to completely rewrite the rendering code using micro-optimizations. According to You, these optimizations can create up to a 100% increase in mounting and initialization speed.
VueJS, like other frameworks, uses a virtual DOM to render its components. In order to speed up the rendering process, the workload of this virtual DOM has to be reduced. 3.0 includes the following features to meet this goal:
Compile Time Hints — by overhauling the rendering process, Vue 3.0 will output better compile time hints that show code optimizations
Component Fast Path — instead of checking if a template object is a component, Vue 3.0 will make the assumption that capitalization marks a component. This assumption takes out the guesswork and speeds up the render process.
Optimized Slots Generation — this seemingly complex term actually boils down to a simple concept: making sure dependencies are tracked by the instances that use them. Currently, whenever either a parent and child component has an updated dependency, both are forced to re-render. However, in 3.0, the parent and child would have different dependencies and will only update when their respective dependencies change. This drastically reduces the number of re-renders that occur on a page.
Static Tree Hoisting — while this is not new (it exists in Vue 2.0), static tree hoisting greatly improves project speeds. As the name suggests, does not re-render static elements that do not have any dependencies. This greatly reduces the work of the virtual DOM and saves a lot of project overhead.
Proxy Based Observations — Vue 3.0 will use ES2015 proxy-based observations in order to track element’s reactivity. Not only does this change eliminate the several cases that Vue 2.0 was not able to support, but it also performs a lot better. According to You, these optimizations can lead to 100% faster component instance initialization and, in comparison to 2.0,
Proxy Based Observations over double the speed, and half the memory usage than the Vue 2.0 observers.
Currently, VueJS is already small (20 kb gzipped). However, thanks to tree shaking (eliminating non-vital code), the estimated size for 3.0 is roughly 10 kb gzipped. This is by removing all libraries that are non-essential for a Vue project and having them available through import statements instead of packed in the main src.
Decoupling Packages — in comparison to its current state, Vue 3.0 is a much more modular experience that relies on its own internal packages in order to run. This makes it customizable and flexible while also giving it transparency that will allow developers to really get into the source code.
Compiler Rewrite — this is one of the features that I’m most excited for. Not only do these changes allow for better IDE support, but now it creates source maps meaning that when there is a runtime error, it will give file location and line numbers of the error. If you work with Vue now, you know that a runtime error message is very little help in identifying the problem. This update should be a breath of fresh air developers.
While a seemingly simple point, I think that this is the main pro of using VueJS — its simple, but powerful, capabilities. These were the aspects highlighted.
Exposing the Reactivity API — the new changes will give devs the ability to explicitly create reactive objects. As well as creating custom re-render hooks. 3.0 also addresses a common complaint of VueJS users: When and why the hell is my component re-rendering?
Now there is a renderTriggered event that allows people to see what is triggering the update. A fantastic feature that will give VueJS even more transparency.
You may be thinking, “So what? People are still going to use React or Angular.” and you may be right. As the current industry standards, React and Angular will likely continue to be the most popular options for component frameworks. However, there are a few interesting things to discuss in Vue 3.0 that may make it more of a competitive alternative in the coming years.
Speed. even now, VueJS provides faster render times than React or Angular. With the micro-optimizations that You discussed, it’s possible that Vue can have half the render times of the other frameworks. This is a key point that could draw some developers away from other environments. The table below shows the speed and memory advantage that Vue 2.0 already has — the new updates should improve these even more.
Adaptability. VueJS is designed to be easy to implement. Whether you want to add it to an existing project or use it to power a SPA, there is a lot of documentation and use cases that help define your needs. The changes made in Vue 3.0, especially exposing the reactivity hooks and a new modular design, make this already flexible language even more powerful. While I’ll go on to highlight the simplicity of VueJS, there are so many features that allow more technical and experienced devs to take full control of their project.
Documentation. This may be a “me issue”, but I personally find Vue’s documentation 10x easier to understand than React’s. In fact, I’ve never even had to complete a Hello World Tutorial or anything in Vue. The documentation was enough for me to understand my usage case and get started. You can take a look for yourself.
To see the full impact of Vue 3.0, we’ll have to wait until its release sometime (hopefully) in 2019. The features that Evan You showed off at VueConf Toronto seem to make Vue more powerful and efficient, so my hopes are high for the new release. What are your thoughts on Vue 3.0 and the great Vue v. React v. Angular debate?