FastComments.com

The Floating Likes Widget Internal Link

The floating likes widget displays a floating box in the bottom right hand of the screen with like and comment counts. You can see it in action on this page!

Users can click the heart to like the page, and it remembers pages they've liked. If they are logged into fastcomments.com, this is tied to their account to help prevent people from liking a page multiple times.

It also automatically detects the user's browser dark mode preferences and changes its skin to a dark version if desired.

Installation - VanillaJS Internal Link

Installation is simple:

Floating Likes Code Example
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-page-likes-floating.min.js"></script>
3<div id="fastcomments-page-likes-floating"></div>
4<script>
5 window.FastCommentsEmbedPageLikesFloating(document.getElementById('fastcomments-page-likes-floating'), {
6 tenantId: 'demo'
7 });
8</script>
9

The type signature of the constructor is:

Configuration
Copy Copy
1
2/**
3 *
4 * @param {HTMLElement} targetElement
5 * @param config
6 * @property {string} tenantId
7 * @property {string} urlId - Change this to set page/article id. By default, it is the page URL.
8 * @property {() => void} [onOpenComments]
9 * @property {object} [sso]
10 * @constructor
11 */
12

It supports sso to tie the reacts to the user's account for authentication.

Currently, only VanillaJS is supported. If you'd like this widget to be added to one of our client libraries, let us know!

Async Version

Floating Likes Code Async Example
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-page-likes-floating.min.js?v=2" async></script>
3<div id="fastcomments-page-likes-floating"></div>
4<script>
5 (function () {
6 function tryLoad() {
7 if (window.FastCommentsEmbedPageLikesFloating) {
8 window.FastCommentsEmbedPageLikesFloating(document.getElementById('fastcomments-page-likes-floating'), {
9 tenantId: 'demo'
10 });
11 } else {
12 setTimeout(tryLoad, 50);
13 }
14 }
15
16 tryLoad();
17 })();
18</script>
19

Installation - WordPress Internal Link

For WordPress, this feature can be enabled by installing a plugin like WPCode and adding the following HTML snippet to the blog footer:

Floating Likes Code For WordPress
Copy Copy
1
2<script src="https://cdn.fastcomments.com/js/embed-page-likes-floating.min.js" async></script>
3<div id="fastcomments-page-likes-floating"></div>
4<script>
5 (function () {
6 function tryLoad() {
7 if (window.FastCommentsEmbedPageLikesFloating) {
8 const articles = document.getElementsByTagName('article');
9 if (!articles.length) {
10 return console.warn('Article not found to show fastcomments likes.');
11 }
12 window.FastCommentsEmbedPageLikesFloating(document.getElementById('fastcomments-page-likes-floating'), {
13 tenantId: '-VuPDR12d-v_',
14 urlId: articles[0].id.replace('post-', '')
15 });
16 } else {
17 setTimeout(tryLoad, 50);
18 }
19 }
20
21 tryLoad();
22 })();
23</script>
24