I just want to keep all javascript separate but before to upload I want to combine into one.
Like Sass do with CSS
I want to do same with Javascript files only.
I just want to keep all javascript separate but before to upload I want to combine into one.
Like Sass do with CSS
I want to do same with Javascript files only.
I've been looking at using some of JavaScriptMVC's functionality for this. Most useful for you would probably be StealJS - http://javascriptmvc.com/docs.html#!stealjs
Using StealJS, you can write code like the following, to ensure some JavaScript is loaded, then run the script body as a callback:
steal('myapp/tabs.js',
'myapp/slider.js',
'myapp/style.css',function(){
// tabs and slider have loaded
$('#tabs').tabs();
$('#slider').slider()
})
Then include it in a page...
<script type='text/javascript'>
steal('myapp/myapp.js')
</script>
or...
<script type='text/javascript'
src='../steal/steal.js?myapp/myapp.js'>
</script>
Then build everything ready for production...
js steal/buildjs path/to/page.html -to myapp
You can take your pick of what of JavaScriptMVC's functionality to use (personally I only use the documentation generation framework at the moment, though time permitting will probably look to pick more up...) - if you're only using Steal for building, then the following might be useful - http://javascriptmvc.com/docs.html#!steal.build.pluginify
Maybe you can use CofeeScript and it's compiler (See the usage)
You might want to consider Spockets to achieve this.
Sprockets was chosen as one of the tools for the Asset Pipeline in Rails 3.0. The Sprockets page on github states its purpose as follows
Sprockets is a Ruby library for compiling and serving web assets. It features declarative dependency management for JavaScript and CSS assets, as well as a powerful preprocessor pipeline that allows you to write assets in languages like CoffeeScript, Sass, SCSS and LESS.