I have this question that came up while working on my current project.
I have a table with a bunch of data that can be modified by the user. According with the modifications performed, a series of boxes updates the information they show (budget calculation, estimated price, things like that).
I thought 2 ways of tackling that.
One is using the setInterval
function. Every, let's say half second, the function that reads all data in the table to update the boxes will be triggered.
The second approach is by setting an event to the whole page:
$(document.body).on("keyup paste", function() {calculate();});
And I wonder which of this two method is the best approach considering performance. So far I would say the second one, because somehow I'm biased against the use of functions triggered over and over, but my understanding of this matter is quite a bit rudimentary and I could be taking the wrong approach.