Making events not trigger so often on a datatable with dc.js I used this answer to make a table with datatables.net and dc.js.  However, I detected a performance issue in this loop:

function RefreshTable() {
    dc.events.trigger(function () {
        datatable.api()
        .clear()
        .rows.add( YearDimension.top(Infinity) )
        .draw() ;
    });
}

count = dc.chartRegistry.list().length
for (var i=count; i--;) {
    dc.chartRegistry.list()[i].on("filtered", RefreshTable);
}
RefreshTable() ;


Because when resetting all the filters with

dc.filterAll();dc.redrawAll();


RefreshTable() is executed once for every dc chart (or dimension?). In my case it's 5 loops at ~500ms each, thus more than 2s for 4 charts and 10k records.

Has someone any idea on how to make it faster? The table should be refreshed only once.
What is ineficient here is always running RefreshTable 5 times. Even if no filters where applied to any charts.  

Make a new function that only resets filters from charts that have a filter.

function filterAll_performance(){
    var chartlist=[chart_year, chart_genre, chart_runtime, chart_globalscore]
    count=chartlist.length;
    for (var i=count; i--;) {
        if(chartlist[i].filters()!=0) {
            chartlist[i].filterAll();
        }
    }
}


and replace

dc.filterAll();


with

filterAll_performance();


This will still refresh the datatable more than once sometimes but it's still better.