0

I have my content.js and my foo.js. If I add foo.js to the content_scripts in the manifest I can call all functions from foo.js from within content.js. But I do not want that because I am afraid of collisions in variable names or function names.

I have thought about using the class identifier for all the code in foo.js, however, Chrome doesn't seem to be ES6-ready and complains about using import/export statements.

How do I wrap my functions in foo.js in a way that I can call them like foo.test() in my content.js? At the moment, test() is callable just like that globally which I want to avoid to keep my code and the environment clean

user2161301
  • 504
  • 5
  • 16
  • Simply wrap the contents of the script with an [IIFE](https://stackoverflow.com/questions/8228281/what-is-the-function-construct-in-javascript). – wOxxOm Jun 29 '21 at 23:26

0 Answers0