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();
Entonces mis preguntas son:
1) How can I remove all dead code from this one .js file? I've tried Cierre de Google 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?
Cualquier ayuda apreciada.
preguntado el 31 de enero de 12 a las 16:01
Murat Derya Özen
jquery minified is small(<20kb), you can use a cdn so it won't have to be downloaded (and thus won't effect performance) and you'll probably use the rest of jquery's functionality at a later date.
I don't understand this : I will be serving this .js file composed of jQuery, ... so I don't want jQuery involved
And noconfilct does replace the dollar sign with an arbitrary symbol of your choosing, thats what you want isn't it ?