@cryptotaxi247 / netdata-1 / commits / 0fe070c11

lower the cpu pressure on the browser when the page does not have focus

Costa Tsaousis (ktsaou) committed Dec 2, 2017 at 22:13 UTC 0fe070c1100d7a109421f6de08b8dacecf1e001d
1 file changed +14 -1
web/dashboard.js
+14 -1
@@ -5145,8 +5145,21 @@ var NETDATA = window.NETDATA || {};
5145 };
5146
5147 NETDATA.chartRefresher = function() {
5148 - var now = Date.now();
5148 //console.log('chartRefresher() begin ' + (now - NETDATA.chartRefresherLastRun).toString() + ' ms since last run');
5149 +
5150 + if(NETDATA.options.page_is_visible === false
5151 + && NETDATA.options.current.stop_updates_when_focus_is_lost === true
5152 + && NETDATA.chartRefresherLastRun > NETDATA.options.last_page_resize
5153 + && NETDATA.chartRefresherLastRun > NETDATA.options.last_page_scroll
5154 + ) {
5155 + setTimeout(
5156 + NETDATA.chartRefresher,
5157 + NETDATA.options.current.idle_lost_focus
5158 + );
5159 + return;
5160 + }
5161 +
5162 + var now = Date.now();
5163 NETDATA.chartRefresherLastRun = now;
5164
5165 if( now < NETDATA.options.on_scroll_refresher_stop_until ) {