jquery/jquery — pull request #1412 by ChrisAntaki (2013-10-30 05:08:57+00:00)
Title: Fix #11809 - Removes memory leak of DOM nodes, in Chrome.

Resolves this bug: bugs.jquery.com/ticket/11809

Modern browsers & IE9+ offer a native attribute for updating a DOM element's inner text. It's named `textContent`. By updating this directly, we can avoid creating two new DOM nodes per text value update.

This removes a memory leak. :)

(IE8 and lower continue to work as before.)

Note: All tests are passing, but no tests were added. This is because JavaScript doesn't have access to DOM node counts. However, we can verify the value added fairly easily.

Step 1: Learn how to record memory usage over time (10s or so), with Chrome Dev Tools.
https://developers.google.com/chrome-developer-tools/docs/timeline#memory_mode

Step 2: Contrast these two Fiddles. Pay attention to the climbing DOM Node Count in the second example.
http://jsfiddle.net/ctZzF/1/ # new optimization
http://jsfiddle.net/ctZzF/2/ # current implementation

Also, it turns out Zepto is already using this optimization.

Feel free to ask any questions. And props to @Sysaninster for getting this started!