When to Use Which?
Meet the loveable Canvas and learn when to use it over the DOM.
We'll cover the following...
Whenever a section heading promises a clear answer, you know that the answer is never clear. This time is no exception. Choosing between the immediate mode-ness of the canvas
and the retained mode-ness of your DOM is not an exclusive decision. It can actually be quite scandalous! You can choose just one, the other, or even both.
In this section, let’s build on the overview you saw in the previous section and look at the advantages and disadvantages of each of the approaches.
The DOM
Since we are talking about the DOM here, you will spend a majority of the time, possibly even all of your time, in this retained mode world. Despite the comforts it provides, it isn’t perfect.
Let’s look at its perfections and imperfections in more detail:
- Easy to use. The DOM abstracts away a lot of the details