Why blaze plays nice with jquery?

Very simple frameworks based on nothing more than template literals can’t be reactive and use jquery by basically any measure. Whats the sauce in blaze? Is it just tracker with diff and jquery?

I’m not sure what the actual question is here, can you clarify?

It’s not that they can’t work with jQuery, but that they’ve been designed to encourage you not to.

When you modify the DOM with jQuery (or VanillaJS), it’s usually done because the state of something has changed.
Your component / view model has an internal representation of state as well.

If your component then tries to do something in the DOM to represent a new state change, and finds the DOM to be different from what it expects, it can cause weird bugs.
At best, the framework will just overwrite the changes you did with jQuery, at worst, it will be functionally broken because certain expectations about the DOM are now wrong (and vice versa when your jQuery code runs)

The paradigm that most front-end frameworks push developers towards is to have a template or render function that creates the DOM that represents the current state.
When you want to change something in the DOM, you should change the state inside your component / view model which will cause a re-render of the DOM.

I think Blaze works well with jQuery because it was designed in a time when most web devs were using jQuery and needed a smooth transition path.
Another reason is that Blaze uses jQuery under the hood and so things like delegated event handlers are done the same way.

As for how, I do believe it is a tracker with diff and jQuery. Though if the template re-runs on something you’ve touched with jQuery, the manual changes will be thrown out and replaced with the result from your Blaze template

1 Like