After more investigation, and thanks to Omri Baumer for he relentless work..
We now understand why we get the error.
The right way to do it is not in the xul file as an include (as I suspected) but via calling the unwrapped js object:
// correct function to load jQuery
var loadjQuery = function(wnd){
var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript("chrome://sbshsafewallet/content/jquery-1.8.3.js", wnd);
var jQuery = XPCNativeWrapper.unwrap(wnd).$;
jQuery.noConflict(true);
return jQuery;
};
// field to store the jQuery for the current document window (as there can be multiple tabs)
var jQueryForWindow = null;
// event to call on window load (didn't include the code, left for reader to do)
windowLoad = function (event)
{
var appcontent = document.getElementById("appcontent"); // browser
appcontent.addEventListener("DOMContentLoaded", pageLoadedInit, false);
}
// load jQuery on DOMContentLoaded event
pageLoad = function (event) {
var doc = event.originalTarget;
var wnd = doc.defaultView;
jQueryForWindow = loadjQuery(wnd);
}
//example of function using the jQuery
function usesjQuery()
{
var $ = jQueryForWindow;
//do something with jquery here
}
Hope this helps all of you that have been stuck!!
Thanks again to Omri Baumer!