9 ms·
> Set up metrics that tracked ratio of jQuery calls used per overall line of code and monitored that graph over time to make sure that it’s either staying const
by ghiculescu 8y ago
> Set up metrics that tracked ratio of jQuery calls used per overall line of code and monitored that graph over time to make sure that it’s either staying constant or going down, not up.
Would love to know how this was done.
- notyourwork 8y agoI would think you could wrap $ or jQuery or whatever in a hook for metrics.
- komali2 8y agoRight, I can visualize how that'd look from a top-level, but it'd be cool if they could share details. What sort of data did they pass along? Was this a standalone little dev tool on everyone's machine? Talk to a server?
- dan-robertson 8y agoI think this is wrong though. If you do a bit of trivial jquery to every element of a list, every time someone changes the “selected” element, then that could count as lots of jquery calls, even though there are few call-sites and not much to change to remove it. I think the more concerning call would actually be some crazy selector, animation, and implicit state change which could be done in just a few calls that happen rarely. With this in mind I think the right metric is #call-sites and not #calls: most of the time the effort required to refactor a jquery call away is not proportional to the number of times the function is called.
- gbuk2013 8y agoAs a guess, wrap each method in a function that records access and run original method? That way you can get stats for each method.
- drivingmenuts 8y agoThat sounds like a case for decorators!
- Reedx 8y agoCouldn't you just count the number of $ to get a decent idea?