Is there a compiler for big javascript projects, I don't want to use coffeescript just plain javascript, but I want it to compile on the clientside, not server side or what ever.
So for example:
app.js
// Libs
include jquery.min.js
include underscore.min.js
include backbone.min.js
// Src
include src/homepage.js
And then in html we would only include app.js which automatically combines those libraries / source files. Same like LESS css.
Are there tools / projects to take care of this? Same story with html, which do include "header.php" and include "footer.php" when it's view logic, we want it on the client side.
Thanks
-
2What you want isn't really called a "compiler" in this case. A JavaScript "minifier" may be what you're looking for, specifically one that has the ability to combine all affected files into a single file. Why do you want to do this, though? By having individual files, they can be individually cached. If you change something in your custom JavaScript, you don't want your users to have to re-download the imported 3rd party libraries again. But if they're all in one file, that's what would happen.David– David2012年05月21日 20:17:50 +00:00Commented May 21, 2012 at 20:17
-
Possible duplicate: stackoverflow.com/questions/10009171/…Cᴏʀʏ– Cᴏʀʏ2012年05月21日 20:18:22 +00:00Commented May 21, 2012 at 20:18
-
1Additionally, I'm not sure what you mean by your varying references to "client side" (and "or what ever" which kind of glazes over an important architectural consideration). What is your goal with this question? What are you trying to accomplish? Or what existing problem are you trying to solve?David– David2012年05月21日 20:19:37 +00:00Commented May 21, 2012 at 20:19
-
@David, it can be a compiler, look at developers.google.com/closure/compilerRuan Mendes– Ruan Mendes2012年05月21日 20:26:10 +00:00Commented May 21, 2012 at 20:26
-
1@David: This is what google calls it, it's good enough for me. Quote from their page : "It is a true compiler for JavaScript. Instead of compiling from a source language to machine code, it compiles from JavaScript to better JavaScript. It parses your JavaScript, analyzes it, removes dead code and rewrites and minimizes what's left. It also checks syntax, variable references, and types, and warns about common JavaScript pitfalls."Ruan Mendes– Ruan Mendes2012年05月21日 20:35:20 +00:00Commented May 21, 2012 at 20:35
1 Answer 1
Take a look at something like headjs or if that's not to your liking then practically any JavaScript compressor will do.