Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Optimize module loading for multiple 'Applications'
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
James Burke  
View profile  
 More options Aug 3 2012, 2:17 pm
From: James Burke <jrbu...@gmail.com>
Date: Fri, 3 Aug 2012 11:17:33 -0700
Local: Fri, Aug 3 2012 2:17 pm
Subject: Re: [requirejs] Optimize module loading for multiple 'Applications'

On Fri, Aug 3, 2012 at 8:47 AM, Justin <justinb...@gmail.com> wrote:
> With require.js 1.x we would do something like this to load all of our code
> into application.js which would then get compressed into a single file:

> require([
>   'common',
>   'app/routers/one_router',
>   'app/routers/two_router',
>   'app/routers/three_router',
> ]);

> application.js would then be loaded via the data-main attribute. Then when
> we wanted to use each router (this is a backbone application) we could just
> do this:

> <script type="text/javascript">
>   require([
>     'app/routers/one_router'
>   ], function(Router){
>     new Router({user_id: <%= current_user.id %>});
>   });
> </script>

If you wrap this in a require call for 'application', or whatever you
use as the data-main module, then I expect it to work:

<script type="text/javascript">
require(['application'], function () {
  require([
    'app/routers/one_router'
  ], function(Router){
    new Router({user_id: <%= current_user.id %>});
  });

});

</script>

If you go that route, then you do not need the data-main. Although it
could be kept, nothing bad should happen if it is kept in.

James


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.