0
var request = new XMLHttpRequest();
   request.onreadystatechange = function () {
        if(request.readyState == 4){
            request.close();
        }
    };
var request = new XMLHttpRequest();
request.open("GET", "http://URLtoExternalJS");
request.send();
var myincludes = request.response.toString();
document.write(myincludes);

How do i add an external source of javascript to the existing .js in the firefox extension ?

  • Ajax is **asynchronous**. Have a look at [How to return the response from an AJAX call?](http://stackoverflow.com/q/14220321/218196) to learn how to work asynchronous code. – Felix Kling Jul 16 '13 at 07:50

1 Answers1

0

Using the Addon-sdk:

You don't have to load javascript with Ajax, just include your js file with PageMod API it will be injected every time you visit a site matching the "include" value you can specify in the PageMod API

edoput
  • 1,212
  • 9
  • 17