One of the highly touted features of ember’s glimmer rendering engine is that, similar to React.js, it does “DOM diffing” and only modifies the actual DOM when it has to. My question is, does this functionality carry through to the route level, i.e. when moving to a completely different route with its own template and component heirarchy, are only the actual needed DOM changes performed?
I ask this because, I am thinking about structuring my app’s routes and their templates in such a way that each is fairly self-contained, i.e. each top level route template contains the main app navigation, sidebar, ect, and I want to make sure that when moving between routes, ember is not having to essentially re-render the entire page and component tree, when only, in most cases, only a small amount of content nested deeper in the template has changed.
Here is a simple illustration of how the route templates are structured:
templates/application.hbs
{{outlet}}
templates/about.hbs
{{app-navbar}}
{{app-sidebar}}
{{#page-content}}
this is the about page content...
{{/page-content}}
templates/contact.hbs
{{app-navbar}}
{{app-sidebar}}
{{#page-content}}
this is the contact page content...
{{/page-content}}
The main reason why i want duplicate those common elements (app-navbar
component, ect) in each top level template, is that in other routes of the app I want to customize certain aspects of them, or maybe even leave them out completely (on a login route for example). To keep my code DRYer, I may even create a {{#simple-page}}{{/simple-page}}
component which renders the entire basic page structure, for those cases where no customization to those global elements are needed.
So, considering that basic structure, will ember/glimmer only update the DOM inside of page-content
, or will it re-render the entire DOM from top to bottom when I navigate between routes?