Users also have options to share your site info with their friends via Email, Copy Link, and Web Share API.
1. Load the required JavaScript and CSS files in the document.
<link rel="stylesheet" href="./dist/css/ensemble-social-share.css" /> <script src="./dist/js/ensemble-social-share.min.js"></script>
2. Load the iconic font for the social icons.
<link rel="stylesheet" href="iconset.tmp.css" />
3. Create a container to hold the social icons.
<div class="social-share" data-social-share></div>
4. Initialize the Ensemble SocialShare and done.
const element = document.querySelector('.social-share');
new ensemble.SocialShare(element); 5. Config the social sharing component with the following options.
new ensemble.SocialShare(element,{
// namespace
ns: 'share',
fx: true,
// root element
root: 'body',
// default classname
className: 'social-share',
// link to share
// defaults to location.href
link: '',
// page title to share
// defaults to window.title
title: '',
// description to share
description: '',
// actions to display
displays: null,
// action intents
intents: {
'facebook': 0,
'twitter': 0,
'whatsapp': 1,
'messenger': 1,
'telegram': 1,
'linkedin': 0,
'send-email': 2,
'copy-link': 3,
'web-share': 4
},
// URI strings
uriform: {
'facebook': 'https://facebook.com/sharer.php?u=%url%',
'ex': 'https://x.com/share?url=%url%&text=%title%',
'whatsapp': 'https://api.whatsapp.com/send?text=%text%',
'messenger': 'fb-messenger://share/?link=%url%&app_id=%app_id%',
'telegram': 'https://telegram.me/share/url?url=%url%&text=%text%',
'linkedin': 'https://www.linkedin.com/sharing/share-offsite?mini=true&url=%url%&title=%title%&ro=false&summary=%summary%',
'send-email': 'mailto:?subject=%subject%&body=%text%'
},
// selector to find link
selectorLink: {
element: 'link[rel="canonical"]',
attribute: 'href'
},
// selector to find title
selectorTitle: null,
// selector to find description
selectorDescription: {
element: 'meta[name="description"]',
attribute: 'content'
},
// Custom parameters for label
label: {},
}); 6. Localize the social sharing component.
new ensemble.SocialShare(element,{
locale: {
label: 'Share',
share: 'Share on %s',
send: 'Send to %s',
subject: 'An interesting thing',
text: 'Hi! There is something may interesting you: %s',
email: 'Send via email',
copy: 'Copy link',
copied: 'Copied link!',
'whatsapp': 'WhatsApp',
'linkedin': 'LinkedIn',
'web-share': 'Share'
},
}); 7. Event handlers.
new ensemble.SocialShare(element,{
onInit: function() {},
onIntent: function() {}
}); 04/12/2025
v0.0.3 (10/03/2023)
The post Social Sharing Libraray For Popular Social Networks – Ensemble SocialShare appeared first on CSS Script.
AMHERST — A suspect arrested in connection with the killing of a woman inside the…
50 Years Ago The Massachusetts Electric Co. will make two acres of land in Williamsburg…
SOUTH HADLEY — A week after voters rejected two tax overrides by a 2-to-1 margin,…
AMHERST — A section of the Norwottuck Rail Trail between South East Street and Station…
SUNDERLAND — Residents will vote on an $800,000 Proposition 2½ override, $357,880 in capital requests…
Amends nearly 90 years in the making are one step closer to becoming a reality…
This website uses cookies.