infocris / pwdhash

pwdhash extension for google chrome browser
https://chrome.google.com/webstore/detail/pwdhash-port/dnfmcfhnhnpoehjoommondmlmhdoonca
8 stars 6 forks source link

Very high CPU load on very dynamic pages #3

Open rkfg opened 8 years ago

rkfg commented 8 years ago

I'm experiencing a noticeable slowdown of the NXT web UI when PwdHash is enabled. Profiler shows that the culprit is discoverPasswordFields function which is consuming CPU. I've found a simple workaround for this:

    var searchInProgress = null;
    var discoverPasswordFields = function(event) {
        if (searchInProgress) {
           clearTimeout(searchInProgress);
        }
        searchInProgress = setTimeout(function() {
           searchInProgress = null;
           if (Self.searchInputs(event)) {
               chrome.extension.sendRequest({controller: 'Background_HTML', action: 'showPwdHashIcon'});
        }}, 1000);
    };

Something like this. It's not quite necessary to find password fields ASAP, one second is enough to prevent cascaded launches because of the DOM updates so it relieves some stress. But it's better to make this search faster of course.