protonet/jquery.inview — pull request #20 by montanajob (2013-11-15 18:08:13+00:00)
Title: As Needed setInterval

We had noticed some sluggishness when simply including the jquery.inview.js plugin, even though we weren't actively using it (no elements were listening for the 'inview' event). This was due to the setInterval call that gets made at the time of the file inclusion. Although the target method (checkInView) doesn't do a whole lot when there are no items in the inviewObjects object, the overhead of the interval call was creating an impact. This change makes the setInterval call conditional based on whether any elements are actually listening for the ‘invew’ event. Clear the interval if all elements are removed.