Performance/Addons/BestPractices: Difference between revisions

Correct MDN link
(Correct MDN link)
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{draft}}
This page has MOVED to MDN:
 
[https://developer.mozilla.org/en/Extensions/Performance_best_practices_in_extensions MDN: Performance Best Practices in Extensions]


A list of recommendations for add-on authors to help keep Firefox fast and responsive.
A list of recommendations for add-on authors to help keep Firefox fast and responsive.
Once it matures, we'll move it over to MDC. Please contribute your tips!


==Use JavaScript Modules==
==Use JavaScript Modules==
Line 116: Line 115:


==apng/agif inappropriate in a lot of cases==
==apng/agif inappropriate in a lot of cases==
Animations require a lot of time to set up (basically decoding many images, not just one; add timers and such to that). Then the image caches often get invalidated, causing your animated images to be reloaded lots of times.  
Animations require a lot of time to set up, as a lot of images are decoded (the frames).
nsITree/<tree> seems to be extra special in this regard, as it seem to
Animated images may have their cached representations evicted quite often, causing the frames of your animated images to be reloaded lots of times, not just once.
not cache animations at all under some circumstances.
nsITree/<tree> seems to be extra special in this regard, as it doesn't seem to
cache animations at all under certain circumstances.


==base64/md5/sha1 implementations==
==base64/md5/sha1 implementations==
Do not ship own base64/md5/sha1 implementations. For base64 there are the built-in atob/btoa functions that do the job just well (also available in modules and js components). Hashes can be computed nsICryptoHash, which accepts either a string or an nsIInputStream. See MDC documentation.
Do not ship your own base64/md5/sha1 implementations. Regarding base64 there are the built-in atob/btoa functions that do the job just well and are available in overlay script as well as in in js modules and components. Hashes can be computed using nsICryptoHash, which accepts either a string or an nsIInputStream. See the [https://developer.mozilla.org/en/nsICryptoHash MDC documentation for nsICryptoHash]


==Image sprites==
==Image sprites==
Line 136: Line 136:
This effectively means that javascript extensions cannot use the nsIThread API anymore to execute own jobs on different threads than the main thread.
This effectively means that javascript extensions cannot use the nsIThread API anymore to execute own jobs on different threads than the main thread.
Consider Web/ChromeWorker as a replacement, which are severely limited in what you can do with them, or just don't use threads.
Consider Web/ChromeWorker as a replacement, which are severely limited in what you can do with them, or just don't use threads.
==Cache Stringbundles==
Consider to cache stringbundles if you have lots and lots of strings in a bundle.
==Generators==
==Leaks==
Confirmed users
945

edits