angelokh
angelokh

Reputation: 9428

Content script inject jquery only when current tab has no jquery

I found out if I inject jquery from manifest, jquery will be injected even current page has already jquery. How can I avoid injecting duplicate js libs such as jquery?

"content_scripts": [
{
        "js": [
                "bower_components/jquery/dist/jquery.min.js",
                "scripts/content/inject.js"
              ],
}

Upvotes: 0

Views: 280

Answers (1)

cyberbit
cyberbit

Reputation: 1365

Content scripts are isolated from the webpage (sandboxed), so conflicts should not occur unless you are doing something advanced like manipulating the DOM to inject your scripts. If you use the manifest, conflicts shouldn't happen.

See here for another answer to this question and here for Chrome's content script docs.

Upvotes: 2

Related Questions