Is the term "preview" that is used here related to the "Preview" button in studio, or the "View Live" button?  Or is this code generic to handle the case wherever the xBlock is rendered?