Skip to content Skip to sidebar Skip to footer

Adding Jquery And Other Js Libraries To Firefox Extension

How do I include jquery and other scripts in my firefox extension? I know this topic is a copy of many other questions asked on SO, but none of them were so helpful. I tried using

Solution 1:

Ok man here's the solution to using Custom Events.

Much thanks to @M.J. Saedy for figuring this one out.

Gist - HERE is a template that will listen to custom events dispatched from non-privileged scope.

Solution 2:

You can't import a library to use in your addon. What you gotta do is inject that into the web page you want to use it on.

Is this a bootstrap addon? Did you make a chrome.manifest? Before injecting to websites you have to make the injectable stuff contentaccessible in the manifest.

so an example manifest file:

content myaddon ./ contentaccessible

then your code of Cu.import('chrome://myaddon/content/jquery.min.js') will work

if you want to use this library in an iframe for like a panel. put in that iframe <script src="chrome://myaddon/content/jquery.min.js">

Let me know if you need more help, if you upload it to GitHub I can see what exactly you're doing

Post a Comment for "Adding Jquery And Other Js Libraries To Firefox Extension"