1

I just want to keep all javascript separate but before to upload I want to combine into one.

Like Sass do with CSS

enter image description here

enter image description here

I want to do same with Javascript files only.

Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • this post might help [combine multiple js files into one][1] [1]: http://stackoverflow.com/questions/4877321/multiple-javascript-files-combine-into-one – Helikaon Mar 26 '12 at 07:15

3 Answers3

1

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

tr00st
  • 331
  • 4
  • 15
0

Maybe you can use CofeeScript and it's compiler (See the usage)

TheodorosPloumis
  • 2,396
  • 1
  • 17
  • 31
0

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.

Steve Weet
  • 28,126
  • 11
  • 70
  • 86