Confirmed users, Bureaucrats and Sysops emeriti
2,088
edits
| Line 7: | Line 7: | ||
==Use JavaScript Modules== | ==Use JavaScript Modules== | ||
'''Instead of the <script> tag in overlays''' | '''Instead of the <script> tag in overlays''': | ||
JavaScript that is loaded via the script tag can slow window load. If your script is not needed as part of window setup, and doesn't need to be loaded for each individual window, then load it on-demand as a module. | JavaScript that is loaded via the script tag can slow window load. If your script is not needed as part of window setup, and doesn't need to be loaded for each individual window, then load it on-demand as a module. | ||
'''Instead of JS XPCOM services''' | '''Instead of JS XPCOM services''': | ||
JavaScript code modules are singletons, are fastloaded, and don't require XPCOM like a full-blown JS XPCOM service does. | JavaScript code modules are singletons, are fastloaded, and don't require XPCOM like a full-blown JS XPCOM service does. | ||
'''Avoid mozIJSSubScriptLoader''' | '''Avoid mozIJSSubScriptLoader''': | ||
Scripts imported this way do not use fastload and are loaded and evaluated from the original source every time loadSubScript is called. Convert any uses to proper modules if possible. | Scripts imported this way do not use fastload and are loaded and evaluated from the original source every time loadSubScript is called. Convert any uses to proper modules if possible. | ||