From: Jo-Philipp Wich Date: Fri, 22 Jun 2018 07:39:30 +0000 (+0200) Subject: luci-base: xhr.js: defer starting poll queue X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=69782ccbc;p=oweals%2Fluci.git luci-base: xhr.js: defer starting poll queue Defer the start of the queue poll loop until the document has been loaded. This allows all XHR.poll() invocations on the page to register their handlers before the first batch of requests is made. Signed-off-by: Jo-Philipp Wich --- diff --git a/modules/luci-base/htdocs/luci-static/resources/xhr.js b/modules/luci-base/htdocs/luci-static/resources/xhr.js index de4476cdd..f1537a448 100644 --- a/modules/luci-base/htdocs/luci-static/resources/xhr.js +++ b/modules/luci-base/htdocs/luci-static/resources/xhr.js @@ -204,7 +204,6 @@ XHR.poll = function(interval, url, data, callback, post) }; XHR._q.push(e); - XHR.run(); return e; } @@ -260,3 +259,5 @@ XHR.running = function() { return !!(XHR._r && XHR._i); } + +document.addEventListener('DOMContentLoaded', XHR.run);