Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

FutureWeb's avatar

What is Patch in vue dev tools?

when I hover over the render time I get Patch, Mount and Render, on one of my components patch is very very slow but I have no idea what it is to begin diagnosing the bottle neck?

0 likes
2 replies
piljac1's avatar
piljac1
Best Answer
Level 28

Vue patching is basically that the framework does a diff between virtual DOMs (when a re-render is triggered: old vs. new) to determine what should be kept and what should be replaced/deleted/created. This is where the key attribute comes into play:

The key special attribute is primarily used as a hint for Vue’s virtual DOM algorithm to identify VNodes when diffing the new list of nodes against the old list. Without keys, Vue uses an algorithm that minimizes element movement and tries to patch/reuse elements of the same type in-place as much as possible. With keys, it will reorder elements based on the order change of keys, and elements with keys that are no longer present will always be removed/destroyed.

If keys weren't set properly with big lists containing heavy content, this will lead to heavy patching, which hinders performance. However, if you have a popular IDE extension, such as Vetur, it will highlight a specific element in red if the usage of the key attribute would be benificial. One important thing to note though is that the key element might not be enough in your case. For example, you might render elements in a loop that contain non-reactive data that will be re-rendered each time for every items of the loop.

Here's a good article that gives some performance enhancement pointers : https://betterprogramming.pub/6-ways-to-speed-up-your-vue-js-application-2673a6f1cde4

Also, it is not mentioned in the above article, but look into <keep-alive>, which can be really useful to improve performance in some cases : https://v3.vuejs.org/api/built-in-components.html#keep-alive

In the docs, they show a basic navigation tabs example, but it can be applied to pretty much any logical context and can increase performance drastically. In this project our team is working on (not perfect, but continuous improvements are being done throughout new sprints), <keep-alive> was used for multiple components in the right sidebar (or bottom section if you're on mobile), so that when you switch from an item to another using the left miniatures, it doesn't get re-rendered/re-processed completely. It was reaaaaaally buggy early on in the project (pre-official release) and this helped us improve the user experience by a lot.

Please or to participate in this conversation.