1

I wrote PHP script which merges multiple js files into one master.js file, to reduce number of requests. When I include files separately, everything works excellent, but when I merge them into one file, javascript (jQuery) totally breaks down, nothing works. At first I thought there was a problem with my php script, but then I manually c/p-ed all js files into master.js file, and the same problem still persists. I tried everything, adding newlines, deleting comments, using jquery noConflict, but nothing helps...

EDIT
I finally solved the problem just by adding simple semicolon at the end of one JS file. Just to clarify what was the exact problem: One of js files consists of one eval() function, and it didn't have semicolon (;) at the end, so when I c/p-ed it inside main.js file along with bunch of other code, I guess it created a problem in a way that all javascript didn't get executed. This is obviously not a problem when including files separately.

Okultis
  • 19
  • 3
  • You might have more luck getting help if you can detail exactly how it 'totally breaks down'... – John - Not A Number Apr 17 '14 at 00:15
  • There are a lot of peculiarities to concatenating Javascript - ordering, semicolons, scope - and there are plenty of solutions already built that deal with them. See [this answer](http://stackoverflow.com/questions/301442/how-do-i-concatenate-javascript-files-into-one-file) for ideas there. As for your home-rolled solution: without any specifics (console errors, etc) we can't really help. – cincodenada Apr 17 '14 at 00:29

0 Answers0