I played with this for a few minutes. As you suggest, I try loading the api in the background page (so this happens only once), and then access it in the popup page via:
var background = chrome.extension.getBackgroundPage();
'background' now points to the window object of the background page, so you can access the Google Visualization api, for example: background.google.visualization.DataTable.
The issue I face is that the chart that is created in the popup window is empty. More specifically, the chart rendering process creates an iframe (where the chart svg is placed) and said iframe appears to be empty.
I tried a few alternatives, but in all cases I end up with an empty iframe:
- executing the draw code in background page context, but pointing to the popup page DOM via chrome.extension.getViews({type: "popup"})[0]
- drawing in the background page and then copying the created chart in the popup page via cloneNode().
I don't have much time right now to follow up, but I suspect the charts code fails drawing when the document hosting the target chart container is not the same document which hosts the API (although I couldn't find any specific js errors while debugging). Alternatively, there could be restrictions in the chrome extensions model to prevent popup page accessing the contents of iframes created by the background page (although this seems likely, if I know chrome extensions well enough).
I'll try to look a bit further into this if I have time, in case nobody picks this up before.