I'm trying to merge all my plugins so I can change from this:
<html>
<head>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/plugin1.js"></script>
<script src="js/plugin2.js"></script>
<script src="js/plugin3.js"></script>
<script src="js/plugin4.js"></script>
</body>
</html>
to this:
<html>
<head>
</head>
<body>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/plugins.min.js"></script>
</body>
</html>
The main idea is to have a tool to "auto import" into my plugins.js file all the plugins I need for my websites and also minify them when compiling. I've been testing with Google Closure (downloadable Java version of the compiler) and I figured how to minify files but I can't import external files. So I'd like to ask you if you could maybe tell me if Google Closure is the tool I'm looking for or if I should use another tool or method.
With "auto import" I mean something like:
PLUGINS/HELLO.JS
function hello(name) {
alert('Hello, ' + name);
}
PLUGINS.JS
@import hello.js
hello('New user');
I hope I made myself clear, I apologize if I messed up with my English.
Thanks!!
I asked myself same question, and found no acceptable answer. Only way to join many files is putting multiple "--js" params in command line:
java -jar compiler.jar --js 1.js --js 2.js --js 3.js --js_output_file all.js
I tried put lines like this (which used in Closure Compiler service UI):
// ==ClosureCompiler==
// @code_url 1.js
// @code_url 2.js
// @code_url 3.js
// ==/ClosureCompiler==
... in "main.js" and compile it - no effect. :(
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With