i wonder if anyone can give me the example where multiple .js files are merged in one .js file so that the source code dont look bulky and page load fast….i have used ddsmoothmenu.js, cufon.js, slides.min.jquery.js, jquery.jcarousel.min.js
This reply has been reported for inappropriate content.
You can use RequireJS which basically calls all JS files from a specified path. For example, if all those files you mentioned are inside a folder named “scripts” and the file inside is named “main.js” you can use the following code:
Then you call the rest of the JS files inside “main.js” –
//By default load any module IDs from js/lib
//except, if the module ID starts with "app",
//load it from the js/app directory. paths
//config is relative to the baseUrl, and
//never includes a ".js" extension since
//the paths config could be for a directory.
Read this documnetation here on how to call your JS files accordingly.
Else, if you want to merge them, just put all the code from each file in to one and compress that file for optimization. Be careful doing this though as it could cause some conflicts and to be fair, I’ve never gone down this route, so maybe someone else could clear things up if that doesn’t work :0)
Yep, you can just copy and paste all of the scripts into one file. I usually do this by leaving a line space in between each script, so I can see where each one starts and ends. This way, you can make sure everything’s working well before you minimize the whole thing into one big chuck. Good luck!