Do not modify the DOM when traversing


Modifying the DOM (Document Object Model) as you traverse it risks making the loop highly resource-expensive, especially in terms of CPU usage. An infinite loop, which consumes a huge amount of resources, might be generated if we add elements at the same time as we traverse it. It is thus highly recommended to NOT perform such edits.


$('a.extlink').each(function(el) {
    $(el).attr('rel', 'external nofollow');
This best practice should only be applied if it is coherent with your project's specifications.
Under CC-By-NX-SA license