How to load content from many posts on a page, only if needed

You could use LazyLoading too, just put the URL for the image in a data-src attribute in the element <img/>, then on click your anchor, copy the data there to the src attribute.

Maybe your lightbox plugin offers an event or config option to put your handler, using jQuery I’d use something like this:

$('a.load-lightbox').click(function(e) {
  e.preventDefault()
  $('.lightbox img').each(function(img) {
    var src = img.data('src')
    img.src = src
  })
})