I wonder why the same JavaScript code is much slower in addition to FireFox (using the Add-on SDK) than it directly works on a web page loaded in FireFox.
For example, this code:
function isPrime(number) { var i, prime = true; for(i = 2 ; i < number ; ++i) { if(number % i === 0) { prime = false; } } return prime; } function sumFirstPrimeNumbers(x) { var i, sum = 0; for(i = 1 ; i <= x ; ++i) { if(isPrime(i)) { sum += i; } } return sum; } var sum = sumFirstPrimeNumbers(15000); console.log(sum);
it takes less than 2 seconds to launch on a webpage opened in FireFox, but takes about 15 seconds to launch in addition to FireFox.
I know that the code may be better, but this is just an example showing how slow it is.
Why is it slower in addition to FireFox?
Is there a way to get it faster (without changing this code, since it, as I said above, is just an example)?
Update:
It looks like this is due to the additional SDK. I did another test: I executed the same code in an add-in that does not use the add-in SDK, and the code runs in about 3 seconds.
Why is there such a huge difference (3 seconds versus 15 seconds) between an add-in using an additional SDK and an add-in not using it?
source share