4

I am trying to figure out how I can use JQuery in my background.js for Google Chrome extension development for Manifest 3. All of the other answers I have found are for Manifest 2.

Thank you in advance for the help.

Aeryes
  • 629
  • 3
  • 10
  • 24

1 Answers1

1

After some more research and time spent trying to figure out how to make this work I figured it out.

To add jquery to your background.js through the use of content functions, you need to add the following to your manifest.

  "content_scripts": [
    {
      "css":["/css/jquery/jquery-ui.min.css", "/css/jquery/jquery-ui.structure.min.css"],
      "js":["/js/jquery/jquery-3.6.0.min.js", "/js/jquery/jquery-ui.min.js"],
      "matches": ["*://*/*"],
      "run_at": "document_end"
    }
  ],
Aeryes
  • 629
  • 3
  • 10
  • 24
  • 1
    It doesn't add jquery to the background script. It adds to the content scripts. You can't use jQuery in a ManifestV3 background script because there is no DOM. – wOxxOm Jul 13 '22 at 04:09
  • @wOxxOm I'm using it in my background.js but through content functions. I should have clarified – Aeryes Jul 19 '22 at 22:43
  • 1
    This is not what "in" means. – wOxxOm Jul 20 '22 at 05:54