JS.require() ... best practices?

58 views
Skip to first unread message

Sascha Herrmann

unread,
Aug 14, 2012, 8:04:11 AM8/14/12
to jsclas...@googlegroups.com
Hi!

I am wondering what the best practice is regarding JS.require().

Our JSF application consists of various modules, that are imported into a "main" application. Most modules have their own JS classes or use some common framework JS classes. The modules are packaged into separate libraries.
I am trying to set up the Javascript classes in a way that allows us to autoload the files (as shown in the Songkick example, we learned a lot from that btw).

Where do I put my JS.require() statements?

List all in my applications at a central point? That would mean that every application needs to know and needs to specify what the modules require, which kind of breaks the encapsulation of the modules.
Or do I put the require statements into the class files, like import statements in Java, and every class file JS.requires the things that the class needs? Does it hurt to require the same class multiple times?

Thanks,

Sascha

James Coglan

unread,
Oct 13, 2012, 3:48:35 PM10/13/12
to jsclas...@googlegroups.com
On 14 August 2012 13:04, Sascha Herrmann <goo...@maledictis.de> wrote:
I am wondering what the best practice is regarding JS.require().

Our JSF application consists of various modules, that are imported into a "main" application. Most modules have their own JS classes or use some common framework JS classes. The modules are packaged into separate libraries.
I am trying to set up the Javascript classes in a way that allows us to autoload the files (as shown in the Songkick example, we learned a lot from that btw).

Where do I put my JS.require() statements?

Sorry I didn't reply to this. It seems very related to this thread, so let's continue the conversation there:

Reply all
Reply to author
Forward
0 new messages