Might be worth caching the $(document) element in cacheEls and then also chaining the .on events in this function to the cached version?