I am creating a simple structure for working with DOM elements. I have about 40 great features in the framework.
Framework Function:
var $ = function(a) { };
And it functions:
Dev.FN = { /* big functions here */ };
This is how I include functions in the framework:
if($.FN) { $.FN.em = em; return $.FN; } $.FN = { em : em }; for(var b in Dev.FN) { if(Dev.FN.hasOwnProperty(b)) { $.FN[b] = Dev.FN[b]; } } return $.FN;
Problem: It creates my 40 big functions for each framework call , I mean: if I call $(element1) , it creates 40 functions for it, then $(element2) again 40 big functions, etc.
How to bind functions from Dev.FN without creating them each time $(element) called?
PS: I also tried the following, but I don't know if this helps:
for(var b in Dev.FN) { if(Dev.FN.hasOwnProperty(b)) { $.FN[b] = function() { return Dev.FN[b].apply(this, arguments); }; } }
source share