title: How to structure JavaScript applications in development and production
body: <p>I'm building my first (non-spaghetti) large JavaScript application. While the introduction of <a href="http://requirejs.org/" rel="noreferrer">RequireJS</a> and other dependency management frameworks for JavaScript makes it easier to split up files, <strong>I'm unclear as to how push a large code base to production</strong>. What I would like is a way to aggregate and minify/uglify my JavaScripts for production, using something like <a href="https://github.com/dsimard/ready.js" rel="noreferrer">Ready.js</a> and <a href="https://github.com/mishoo/UglifyJS" rel="noreferrer">UglifyJS</a>. Or some other approach, if it makes sense.</p>
  
  <p><strong>How do developers with large JavaScript apps in production handle their structure in development and in production?</strong></p>
  
  <p>I could, for example, use RequireJS in development and then use Ready/Uglify to aggregate/minify. But then my code would have pointless <code>require()'s</code> scattered throughout. I'm sure there's a better approach.</p>
  
  <p>I'm also confused about including jQuery within these files. Should I be wrapping each and every separate jQuery file (for example Backbone views that use jQuery) within their own separate <code>$(document).ready(function(){...})</code>? That seems very un-DRY.</p>