The other day I submitted an addon to Mozilla Addons for the preliminary review. The reviewer gave me this recommendation:
Use JavaScript modules where possible. These will only be imported if they haven't been loaded yet and reduce memory consumption and response times. See https://developer.mozilla.org/en-US/docs/JavaScript_code_modules and https://developer.mozilla.org/en-US/docs/JavaScript_code_modules/Services.jsm . Services.prefs ... is interesting for you.
Now, I was using this to load my prefs:
var prefs = Components.classes["@mozilla.org/preferences-service;1"] .getService(Components.interfaces.nsIPrefBranch);
and later...
var mypref= this.prefs.getBoolPref("extensions.myaddon.mypref");
Now, I looked at the page references and am not sure how to do it the way the reviewer suggests. I can't find an example of how to do it that way. The best I could do was to add this:
Components.utils.import('resource://textlink-modules/prefs.js'),
...but I couldn't figure out how to refer to mypref after that. I am new to addons, so if someone could help me out, that would be great. How can I do it his way?