loading multiple JS files in Content script

3,183 views
Skip to first unread message

Julien Genestoux

unread,
Apr 25, 2011, 7:27:45 PM4/25/11
to chromium-...@chromium.org
Hello,
I know it's possible to load several JS files in a content script and that's great.
What would be even better is if I could just put a folder and it would load all files in it, or define some kind of pattern, like "js/*.js" and it would load all files matching this.
Is that doable in any way?

Thanks,

Arne Roomann-Kurrik

unread,
Apr 25, 2011, 9:40:38 PM4/25/11
to Julien Genestoux, Chromium-extensions
Unfortunately not.  Hopefully you're not writing an extension with a prohibitive number of javascript includes for content scripts, though.  If the amount is too many to include by hand, I would suggest using a JS compiler or minifier to concatenate the files together before loading them into your extension.

~Arne


--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Julien Genestoux

unread,
Apr 25, 2011, 11:15:15 PM4/25/11
to kur...@chromium.org, Chromium-extensions
Yup, that's what I expected... It's not so much that it's big files, but for the sake of clarity, I wanted to split a decently big file (couple hundred locs) into several small ones.
Thanks though!

Envoyé de mon iPad

Erdogan Camcioglu

unread,
May 2, 2011, 4:17:14 AM5/2/11
to Julien Genestoux, kur...@chromium.org, Chromium-extensions
Why don’t you modify “content_scripts” part of manifest.json file as follows?
"content_scripts": [
    {
......
......
 
  "js": [
   "first.js",
   "second.js",
   "third.js",
   "fourth.js",
   "contentscript.js"
   ],
......
......
It works for my extension.
From: Julien Genestoux
Sent: Tuesday, April 26, 2011 6:15 AM
To: kur...@chromium.org
Cc: Chromium-extensions
Subject: Re: [crx] loading multiple JS files in Content script

Arne Roomann-Kurrik

unread,
May 2, 2011, 12:42:01 PM5/2/11
to Erdogan Camcioglu, Julien Genestoux, Chromium-extensions
That's what he was doing, but wanted a way to not have to list them all individually.

~Arne
Reply all
Reply to author
Forward
0 new messages