ceth
ceth

Reputation: 45295

Structuring the js functions in project

I have a file client/events/entity.js where I want to bind some function to multiple events. I can put this function in the same file:

//  save changes
function save_changes(id) {
   // ...
}

Template.bookmarks.events({
    'click .save_changes' : function(e,t) {
      save_changes(e.target.id);
    }

   /// ...
}

Or it will be better if I move this function to client/lib/save_changes.js file ?

Upvotes: 0

Views: 48

Answers (1)

elixenide
elixenide

Reputation: 44831

There's no reason to move it to a different file; you'll just trigger an additional server request when a user visits the page, which will decrease overall performance.

Upvotes: 1

Related Questions