I am creating a PageAction Chrome extension with a popup and content script .
I want to use jQuery in a popup to manipulate its DOM to represent the data (which I slipped from the site itself using jQuery entered as the content of the script). I know that I can load jQuery directly in popup.html and use it. However, I wanted to see if I could only load jQuery once on the background image and access it in a popup, rather than loading it every time the popup opens.
To do this, I tried the following in a popup window:
var background = chrome.extension.getBackgroundPage(); var $ = background.jQuery; $("#testID").innerHTML = "testing jQuery";
but it didnโt work - $("#testID") was undefined. I checked that jQuery is loaded on the wallpaper and uses alternative names for $, for example. jq, jQuery etc. also did not work.
Any suggestions on how to make this work?
source share