33
edits
(→Reduce File I/O: Jars are not necessary for fx4+ (without em:unpack)) |
|||
Line 83: | Line 83: | ||
==Unnecessary onreadystatechange in XHR== | ==Unnecessary onreadystatechange in XHR== | ||
addEventListener(load/error) | addEventListener(load/error) and/or xhr.onload/.onerror are usually sufficient for most uses and will only be called once, contrary to onreadystatechange. | ||
When using XHR in websites people tend to use onreadystatechange (for | When using XHR in websites people tend to use onreadystatechange (for | ||
compatiblity reasons). Often it is enough to just load the resource or handle errors. load/error event listener are far less often called than onreadystatechange, i.e. only once, and you don't need to check readyState or figure out if it is an error or not. | compatiblity reasons). Often it is enough to just load the resource or handle errors. load/error event listener are far less often called than onreadystatechange, i.e. only once, and you don't need to check readyState or figure out if it is an error or not. | ||
Only use onreadystatechange if you want to process the response while it is still arriving. | |||
==Removing Event Listeners== | ==Removing Event Listeners== |
edits