Fix preview with javascript and attachments