social-junk

Asynchronously load social libraries as needed. Or not.

Usage no npm install needed!

<script type="module">
  import socialJunk from 'https://cdn.skypack.dev/social-junk';
</script>

README

Social Junk

Why

While social buttons are ugly, probably horcruxes, and definitely tracking you, there are times when they are unavoidable. This library is written to limit their interactions and overhead by asynchronously loading social libraries only when needed.

Note: You should probably block social buttons.

Usage

UMD so use how you would like.

Options

facebookAppId

Optionally set your Facebook App ID.

Examples

Initialize:

new SocialJunk();

Initialize with Facebook App ID:

new SocialJunk( {
    facebookAppId: '123456789'
} );

Listen for an event:

document.addEventListener( 'twitter:loaded', function ( event ) {
    console.log( event.type );
} );

Events

Facebook

facebook:libraryLoaded

Library script has loaded.

facebook:loaded

All buttons are rendered.

Google+

googleplus:libraryLoaded

Library script has loaded.

Twitter

twitter:libraryLoaded

Library script has loaded.

twitter:rendered

Parameter: event.rendered HTML element

Button is rendered.

twitter:loaded

Parameter: event.loaded array of HTML elements

All buttons are rendered.

Contributing

Dudes (like Facebook) tend to change things up often. If this happens, feel free to fix.

Run the following for the uglified version:

npm run build-js

Browser Support

Probably IE 9+ ¯_(ツ)_/¯