当前位置: 动力学知识库 > 问答 > 编程问答 >

How to inject lots of Javascript files into CHROME EXTENSION?

问题描述:

I want to load lots of linked Javascript files by loading one core Javascript file.

There exist linked Javascript files.


Core.js

sub_1.js, sub_2.js, sub_3.js, ......, sub_n.js


How can I load these linked Javascript files into content script?

There are so many Javascript files. I want to load these by declaring only one core Javascript files.

I know ways to load each Javascript file.

[manifest.json]

....

"content_scripts": [

{

"matches": [....],

"js": ["core.js", "sub_1.js", "sub_2.js"....]

}

],

....

or

[background.html]

<script>

...

chrome.tabs.executeScript(null, { file: "core.js" }, function() {

chrome.tabs.executeScript(null, { file: "sub_1.js" }, function() {

chrome.tabs.executeScript(null, { file: "sub_2.js" }, function() {

....

});

});

});

...

My final objective is to inject TinyMCE into content script.

I want to solve this problem in advance.

Help me please.

网友答案:

Take a look at RequireJS. http://requirejs.org/ That should do what you want.

网友答案:

I would go for apache ant, create a build script which will pack all needed js-files into one single file.

The necessary code is shipped with the tinymce developer version. Here is some more information: http://www.tinymce.com/forum/viewtopic.php?id=27812.

分享给朋友:
您可能感兴趣的文章:
随机阅读: