I use a library which provides lots and lots of utility functions. It's based on jQuery, so I have to include jQuery too. Both of these libraries are huge in size but I only use a single functionality in a single function only once.
I've gathered all the code in a single .js file and measured code coverage using jscoverage. It seems that only 13% of the statements are executed. This means more than 200KB's of dead code.
Here is what the combined.js file looks like:
// jQuery code copy-pasted here
...
// libX code copy-pasted here
...
libX().doSomething();
So my questions are:
1) How can I remove all dead code from this one .js file? I've tried Google Closure but then the code doesn't work. I guess it messed up with all the jQuery stuff.
2) I will be serving this .js file composed of jQuery, another library and my own little code to 3rd parties so I don't want jQuery involved, even with noconflict mode. How can I tailor this to my own needs? Perhaps replace the dollar sign with an arbitrary symbol or something?
Any help appreciated.