Efficient Traversal and Manipulation of the DOM with Native JavaScript Using For/In Loop
You should not iterate over an array or array-like object using a foreach loop,
you should use a good old-fashioned for loop instead:

var items = document.querySelectorAll('.item'); 
for (var i = 0; i &lt; items.length; ++i) { ... }


Yes, this sequential for loop doesn't look as elegant as a foreach loop,
but unfortunately, using a foreach loop for arrays in JavaScript is incorrect. 

As for this:

var items = document.querySelectorAll('.item'); 
for (var i = 0; i &lt; items.length; ++i) {
  var item = items[i];
  var link = item.querySelector('a');
  var img = item.querySelector('img'); 
}


Having two .querySelector lookups in each iteration is not really a problem, 
because the lookups are done on a small object, a tiny subset of the entire document.

I wrote the loop body slightly differently from your original:


I put the value of items[i] in a local item variable.
This is to avoid duplicating item[i].
It's good to eliminate duplications,
because if you ever need to change something, you need to do it in all duplicates,
which is potentially error-prone.
I declared link and img on two lines.
This is slightly more verbose, but a bit clearer.