gitdefence / game-off-2012

Build networks, destroy bugs
http://www.justinmcgirr.com/gitdefence/master/game/
5 stars 1 forks source link

Get rid of jQuery #119

Open crazy2be opened 11 years ago

crazy2be commented 11 years ago

Right now, jQuery takes ~97kb of bandwidth on first load, out of a total page weight of ~347kb. I rewrote InputHandler to not rely on jQuery anymore, so the only dependencies in our code should be for a handful of utility functions, like jQuery.clone(), jQuery.merge(), and jQuery.isFunction(). We should be able to steal just these functions from the jQuery source, or remove our dependency on them if we no longer need them (jQuery.clone(), in particular, used to be used a lot for Rects and Vectors, but I'm not sure if it's used anymore).

crazy2be commented 11 years ago

So jQuery.clone() should be able to go away:

./game/towerAttackType.js:        var newAttTemplate = cloneObject(attackTemplate); //Clone it just incase it has its own attributes
./game/towerAttackType.js:            var dist = cloneObject(start);
./game/towerAttackType.js:                start = cloneObject(end);
./game/towerAttackType.js:                start = cloneObject(end);
./game/towerAttackType.js:                start = cloneObject(end);
./game/tower.js:        var dis = cloneObject(t1.tpos.center());
./game/commonFncs.js:function cloneObject(object) {

Almost everywhere it's used is an error, (or at least looks that way), and the first case can be supplanted by a simple clone method.

crazy2be commented 11 years ago

mergeObject is actually completely unused.

crazy2be commented 11 years ago

And we should be able to replace jQuery.isFunction with a simple typeof check: http://stackoverflow.com/questions/5999998/how-can-i-check-if-a-javascript-variable-is-function-type