ApeSander
ApeSander

Reputation: 11

Share script between background and content scripts

I am working on a chrome extension. I need to process some data using the d3 library (d3.v7.min.js), but I need to do this both in the service worker (the background.js) and a content script (geotrackr.js). What is a clean way to go about this? code structure

I got the libaries working in the content script, but they are not accessible through the background.js.

A solution could be to send a message to geotrackr.js, which then processes the data with the library and then sends a response back to the background.js, but that just feels very wrong and I am not sure if that is a good solution performance wise.

Upvotes: 0

Views: 9

Answers (0)

Related Questions