Aris-t2 / CustomJSforFx

custom scripts
GNU General Public License v3.0
236 stars 22 forks source link

Performance improvement suggestion for 2 userscripts #94

Open emvaized opened 1 year ago

emvaized commented 1 year ago

During my testing of scripts favicon_in_urlbar.uc.js and tab_label_in_urlbar.uc.js I figured out, that DOMContentLoaded, load and TabOpen event listeners are not really neccessary for scripts to function. Basically, 99% of cases are covered by TabAttrModified event listener (if not all) — at least in the current Firefox version I tested (v115).

Moreover, by removing TabOpen listener and adding a check to react only to selected tabs changes, scripts became significally easier on browser startup. Without these changes they processed whatever many tabs user had automatically restored on browser startup — each sending few TabOpen and TabAttrModified events.

I guess, the only downside is — tab_label_in_urlbar.uc.js will temporary show url in the label widget for new tabs which are still loading and don't have any label yet.

Aris-t2 commented 1 year ago

I agree, removing unnecessary DOMContentLoaded, load and TabOpen listeners improves performance. The script favicon_in_urlbar.uc.js had a few other issues needed to be resolved, before uploading a new version.