The usual DOM-diffing algorithm compares every single thing: "has this div changed? Has the class changed? Has the <p> changed?"
This uses the knowledge of Handlebars to make the diffing algorithm smarter: you don't need to check if the <div> or its class has changed, it never will. You don't need to check if the <p>'s contents have changed, it never will. This means less to diff, which means more speed.
This is the advantage of using a declarative syntax for templating: this analysis can be done entirely at compile time.
A handlebars template might look like this:
The usual DOM-diffing algorithm compares every single thing: "has this div changed? Has the class changed? Has the <p> changed?"This uses the knowledge of Handlebars to make the diffing algorithm smarter: you don't need to check if the <div> or its class has changed, it never will. You don't need to check if the <p>'s contents have changed, it never will. This means less to diff, which means more speed.
This is the advantage of using a declarative syntax for templating: this analysis can be done entirely at compile time.