Skip to content

Commit

Permalink
Removed lazy load from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
patricktobias86 committed May 11, 2024
1 parent 8ec1fb1 commit 5d99f68
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 61 deletions.
51 changes: 0 additions & 51 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,57 +67,6 @@ class TelegramCommentsPlugin {
data-dark="${darkNumber}"></script>
`;

if (this.config.lazyload) {
scriptToLoad = `
var comments_element_to_check = document.getElementById('comments_thread');
if ('IntersectionObserver' in window) {
var iObserver = new IntersectionObserver(
(entries, observer) => {
entries.forEach(entry => {
if (entry.intersectionRatio >= 0.1) {
(function () {
var d = document, s = d.createElement('script');
s.src = '//comments.app/js/widget.js?3';
s.async = true;
s.setAttribute('data-comments-app-website', '${this.config.siteId}');
s.setAttribute('data-limit', '${this.config.limit}');
s.setAttribute('data-page-id', '${uniquePageID}');
s.setAttribute('data-color', '${this.config.color}');
s.setAttribute('data-dislikes', '${dislikesNumber}');
s.setAttribute('data-outlined', '${outlinedNumber}');
s.setAttribute('data-colorful', '${colorfulNumber}');
s.setAttribute('data-dark', '${darkNumber}');
(d.head || d.body).appendChild(s);
})();
observer.unobserve(entry.target);
}
});
},
{
threshold: [0, 0.2, 0.5, 1]
}
);
iObserver.observe(comments_element_to_check);
} else {
(function () {
var d = document, s = d.createElement('script');
s.src = '//comments.app/js/widget.js?3';
s.async = true;
s.setAttribute('data-comments-app-website', '${this.config.siteId}');
s.setAttribute('data-limit', '${this.config.commentsView}');
s.setAttribute('data-page-id', '${uniquePageID}');
s.setAttribute('data-dislikes', '${dislikesNumber}');
s.setAttribute('data-outlined', '${outlinedNumber}');
s.setAttribute('data-colorful', '${colorfulNumber}');
s.setAttribute('data-dark', '${darkNumber}');
(d.head || d.body).appendChild(s);
})();
}
`;
}

if (this.config.cookieBannerIntegration) {
cookieBannerGroup = 'gdpr-blocker/' + this.config.cookieBannerGroup.trim();
consentScriptToLoad = `document.body.addEventListener('publii-cookie-banner-unblock-${this.config.cookieBannerGroup.trim()}', function () {
Expand Down
12 changes: 2 additions & 10 deletions plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "The Telegram plugin lets site owners easily add support to let Telegram users comment on the website.",
"license": "GPL-3.0",
"author": "patricktobias86",
"version": "1.0.0",
"version": "1.0.1",
"scope": "site",
"minimumPubliiVersion": "0.39.0",
"usePluginSettingsView": false,
Expand Down Expand Up @@ -141,14 +141,6 @@
"value": "",
"type": "text"
},
{
"name": "lazyload",
"label": "Lazy load",
"note": "Enable this option if you want to preload Telegram scripts when users scroll down the page to the comments area.",
"group": "Advanced options",
"type": "checkbox",
"value": true
},
{
"name": "cookieBannerIntegration",
"label": "",
Expand Down Expand Up @@ -188,4 +180,4 @@
]
}
]
}
}

0 comments on commit 5d99f68

Please sign in to comment.