最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Chrome Extension Error Loading Jquery - Stack Overflow

programmeradmin0浏览0评论

I am working on a chrome extension and my content script was throwing an error

$/jQuery not being defined.

So I tried embedding jquery using my manifest file and I downloaded jquery in my extension folder but for whatever reason I am receiving this error --

Denying load of chrome-extension://gfdmfdmhnoenciioooikdifmdkechdbl/jquery-1.10.2.min.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

I tried a couple of things with my manifest file but nothing seems to work so now Im trying this and its still giving me the error --

{
    "manifest_version": 2,

    "name":    "My Extension",
    "version": "0.0",
    "offline_enabled": false,

    "content_scripts": [{
        "matches":    ["*://*.sitedomain/*"],
        "js": [
                "jquery-1.10.2.min.js", 
                "content.js"
            ],
        "run_at":     "document_end",
        "all_frames": false
    }]
}

I am unable to edit the actual site its to be used on so I can't load jquery the old fashion way in the header, thats why Im trying to load with the extension so my content script will work. Any help is appreciated.

I am working on a chrome extension and my content script was throwing an error

$/jQuery not being defined.

So I tried embedding jquery using my manifest file and I downloaded jquery in my extension folder but for whatever reason I am receiving this error --

Denying load of chrome-extension://gfdmfdmhnoenciioooikdifmdkechdbl/jquery-1.10.2.min.map. Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension.

I tried a couple of things with my manifest file but nothing seems to work so now Im trying this and its still giving me the error --

{
    "manifest_version": 2,

    "name":    "My Extension",
    "version": "0.0",
    "offline_enabled": false,

    "content_scripts": [{
        "matches":    ["*://*.sitedomain./*"],
        "js": [
                "jquery-1.10.2.min.js", 
                "content.js"
            ],
        "run_at":     "document_end",
        "all_frames": false
    }]
}

I am unable to edit the actual site its to be used on so I can't load jquery the old fashion way in the header, thats why Im trying to load with the extension so my content script will work. Any help is appreciated.

Share Improve this question edited Dec 11, 2013 at 5:43 Sachin Jain 21.9k34 gold badges110 silver badges176 bronze badges asked Dec 11, 2013 at 5:24 user3089477user3089477 713 silver badges8 bronze badges 4
  • 1 jquery-1.10.2.min.map is in the error but you have mentioned jquery-1.10.2.min.js in your content script. Are you sure there is no typo in path of jquery ? – Sachin Jain Commented Dec 11, 2013 at 5:30
  • @blunderboy I have both jquery-1.10.2.min and jquery-1.10.2.min.map in my folder, and I dont see no type. I tried including .map file with web_resources... and still Im receiving the error – user3089477 Commented Dec 11, 2013 at 6:17
  • Are you using source map ? – Sachin Jain Commented Dec 11, 2013 at 6:24
  • possible duplicate of jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found) – Teepeemm Commented Jul 4, 2015 at 3:04
Add a ment  | 

1 Answer 1

Reset to default 3

Just remove this line from the top of jquery file

//@ sourceMappingURL=jquery-1.10.2.min.map

If you check the source of Jquery 1.10.2, it has included source map line on the top. I hope you are not using Source Maps. For more details just check these links:

  1. http://www.html5rocks./en/tutorials/developertools/sourcemaps/
  2. jQuery's jquery-1.10.2.min.map is triggering a 404 (Not Found)

Alternate approach

  1. Download the source map file from jquery downloads page and put jquery-1.10.2.min.map in the extension directory.
  2. Download unpressed source code as well and put in the extension directory.
  3. Basically you need three files [SourceMap, Compressed, Unpressed].
  4. Add these map file path and unpressed file paths to web_accesible resources.
发布评论

评论列表(0)

  1. 暂无评论