Simple javascript code to create an image caption
Not a comment on functionality, but here:

const wideImg = document.querySelector('.full-width-image-atf img'),
      captionText = wideImg.getAttribute('alt'),
      captionInnerHTML = '&lt;span class="image-caption"&gt;' + captionText + '&lt;/span&gt;',
      caption = document.createElement('div');


I don't think chaining declarations using , like you are is a good idea for a couple reasons:


It isn't immediately clear that all the variables involved are being declared as const. Yes, you can tell if you check the indentation, or notice the commas at the end, but it isn't as clear as explicit consts all the way down.
It makes refactoring more of a pain. Say in the future you want to break that up and maybe stick a log call in there or some other non-declaration. Now you need to manually replace the commas with semi-colons, and remember to add const to all the now separate declarations.


I'd suggest just writing it out fully from the start, and maybe space out the last one since it has a separate purpose:

const wideImg = document.querySelector('.full-width-image-atf img');
const captionText = wideImg.getAttribute('alt');
const captionInnerHTML = '&lt;span class="image-caption"&gt;' + captionText + '&lt;/span&gt;';

const caption = document.createElement('div');