0

I am working with chrome extension. I want to create a function in my current content.js, then add the function to another.js file

I have created a new script in content.js using this code:

  var s = document.createElement('script');
  s.src = chrome.runtime.getURL('another.js');
  (document.head || document.documentElement).appendChild(s);

(I have another.js in the same directory)

Now, if I am in content.js, is there a way to create a new function myfunction() and add it to another.js file (from content.js) ??

Mikael
  • 171
  • 2
  • 12
  • 1
    https://stackoverflow.com/questions/950087/how-do-i-include-a-javascript-file-in-another-javascript-file this might help. – Julius Limson Jul 23 '19 at 01:17
  • 1
    The code inside a ` – wOxxOm Jul 23 '19 at 04:34

0 Answers0