What's the best way to assemble Javascript modules server-side in Python?
<p>I'm planning an extensible web app where base objects are extended by JavaScript modules which plug in. Each JavaScript object may just be an independent bit of code, or I might be building a large object to simulate a module namespace. I'll be using a Django back-end and Backbone.js, since you asked.</p>

<p>The system should be easily modular, so adding a new module should be a question of just dropping in another file or database row or whatever. The person installing the module shouldn't have to edit a large JavaScript file manually (or run a special script, in an ideal world).</p>

<p>I have two options: just serve each JS file separately or get the server to assemble them. The first option will get ungainly when a large number of plugins is reached. </p>

<p>I'm looking into the best way to implement the second option: assembling a JavaScript file from a lot of small JavaScript snippets. I could just do some blind string concatenation, but there may be a Python library that can do this and take account of problems I haven't foreseen.</p>
