I'm develop some extension for Mozilla FireFox using Addon SDK. My main.js now is very huge, contains a lot of code in all kinds. It's possible to slice them into few custom js files?
main.js - Loader
Unit1.js - Do job A
Unit2.js - Do job B
Unit3.js - Do job C
or any good advice for developing very functional extensions.
You can create and
require()"local" modules. Also read up on the Module structure of the SDK.Therefore, you may want to try to modularize your stuff.
lib/joba.jslib/main.jsOf course, any module can use
require(), but beware of circular imports.It's up to you what to put into what module. E.g. one module could implement a single "class", while another module could implement a collection of functions, or another module could be for background requests and yet another module of all UI stuff.
Maybe looking at the SDK itself, which is organized in modules, and/or look into what other stdlibs do, like the Python stdlib, or the go stdlib, etc.