Add loading="lazy" to iframe (#383)

Lazy loads the utterances iframe
This commit is contained in:
techboyg5 2020-11-14 14:49:59 -06:00 committed by GitHub
parent 23860d6168
commit 7ab9cd94d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,7 +80,7 @@ const url = `${utterancesOrigin}/utterances.html`;
script.insertAdjacentHTML(
'afterend',
`<div class="utterances">
<iframe class="utterances-frame" title="Comments" scrolling="no" src="${url}?${param(attrs)}"></iframe>
<iframe class="utterances-frame" title="Comments" scrolling="no" src="${url}?${param(attrs)}" loading="lazy"></iframe>
</div>`);
const container = script.nextElementSibling as HTMLDivElement;
script.parentElement!.removeChild(script);