1

Possible Duplicate:
Make File for Javascript

Actually i am writing some javascript for testing purpose. i want to use multiple javascripts in which functions are defined. Is there any way to achieve this ? I think Make file is the way. But i don't know that also. I want to generate make file. Can any body suggest me how is to be done?

Community
  • 1
  • 1

3 Answers3

1

Creating makefile is an interesting solution, but you can also use require.js library to set the sequense of loaded scripts.

Just_Mad
  • 4,029
  • 3
  • 22
  • 30
  • Actually i am doing testing of standalone product which QT based. I am using Javascript as scripting language. I have some .js files which contains fuctions. i am sourcing all files individually which is not the good way. In main file i want to source them all at once. Suggest me the answer with appropriate info. ? – Navrattan Bansal Mar 13 '12 at 12:47
  • +1 for letting know about this project. I like it also becaus it does some nice optimisations, and can be used in any environment. – Ernest Mar 13 '12 at 17:35
0

If you looking to combine multiple scripts as one. You can the use build script Boilerplate.

Why to use it? Its not only about scripts.

Combines and minifies javascript (via yui compressor)
Inlines stylesheets specified using @import in your CSS
Combines and minifies CSS
Optimizes JPGs and PNGs (with jpegtran & optipng)
Removes development only code (any remaining console.log files, profiling, test suite)
Basic to aggressive html minification (via htmlcompressor)
Autogenerates a cache manifest file (and links from the html tag) when you enable a property in the project config file.
Revises the file names of your assets so that you can use heavy caching (1 year expires).
Upgrades the .htaccess to use heavier caching
Updates your HTML to reference these new hyper-optimized CSS + JS files
Updates your HTML to use the minified jQuery instead of the development version
Remove unneeded references from HTML (like a root folder favicon)
Runs your JavaScript through a code quality tool (optional)
Community
  • 1
  • 1
Starx
  • 77,474
  • 47
  • 185
  • 261
  • Actually i am doing testing of standalone product which QT based. I am using Javascript as scripting language. I have some .js files which contains fuctions. i am sourcing all files individually which is not the good way. In main file i want to source them all at once. Suggest me the answer with appropriate info. ? – Navrattan Bansal Mar 13 '12 at 12:46
  • @user970553, Using the ant-build script link in my answer is the right way to do this. Check it out, it is very easy – Starx Mar 13 '12 at 12:52
  • +1 Looks very good, but still.. it requires Ant. – Ernest Mar 13 '12 at 17:33
0

If you have several separate files and you want to append them all it into one file before, f.i. using it one your website, then any script or tool is good: Make, Rake, Cake, or your own, in your language of choice. If it goes to the web, it should be also compressed. Now how to do it, is beyond scope of this question, there are loads of articles on the web about all those topics. You are encouraged to come back when (if) you hit some more detailed problem.

Ernest
  • 8,701
  • 5
  • 40
  • 51
  • Actually i am doing testing of standalone product which QT based. I am using Javascript as scripting language. I have some .js files which contains fuctions. i am sourcing all files individually which is not the good way. In main file i want to source them all at once. Suggest me the answer with appropriate info. ? – Navrattan Bansal Mar 13 '12 at 12:46
  • Sound like Require.js is good for you, as Just_Mad proposed. – Ernest Mar 13 '12 at 17:31