jQuery Duff's Device

Summary

Use Duff's device for faster* loops.

Author

Chad Smith (email)

Requires

Download

jquery-duff.js (842 bytes)

License

Dual licensed under the MIT and GPL licenses.

Usage

Use: $(element).duff(function(){...}); or $.duff(element,function(){...});

In place of: $(element).each(function(){...}); and $.each(element,function(){...});

*Duff's device is faster in many cases, but not every case. Loop speed depends on the browser and number of iterations, and can differ on each run.

Version History

Support

Benchmarks

Iterating the array [100000,...,1]

Each: 0 ms

Duff: 0 ms

Appending 250 links

Each: 0 ms

Duff: 0 ms

Modifying the link text

Each: 0 ms

Duff: 0 ms

© 2009 Mktg Dept