Copying a large number of DOM elements
As a followup to your "selfie" answer :D

new Date().getTime()

// to

Date.now()


The effect is the same, but the difference is that you avoid generating a new Date object for the operation. Date.now() just returns the current timestamp.

$galleryItem.innerHTML = $gridItems[i].innerHTML


One problem with innerHTML is that it carries the state of whatever it was you fetched it from. This means if something happens to add the attribute data-foo="bar" into the element or its descendants, this gets copied over. You don't know what data-foo="bar" entails, and there might be side-effects.

An actual case is jQuery using an internal cache mapping of element references. It uses key of that mapping as a custom attribute on the element referenced. Using innerHTML would carry over this attribute to the new stuff, when it should not.