Quick Jquery: How to reduce DOM traversing


Ofcourse, less the DOM will get traversed quick will be the output. Therefore here is the trick to cache the element in jquery so as to reduce traversing.

Here we go:

Wrong Way

var myElement = $('#anyElement');



Right Way

var myElement = $('#anyElement');

And its done

  • September 14, 2010
8 Best Free Stock Video Websites for Tiktok, Reels, and Shorts Top 5 PHP Frameworks: Fast and Secure