Maintainable Social Script Integration

Published on December 19, 2014 (↻ February 5, 2024), filed under (RSS feed for all categories).

This and many other posts are also available as a pretty, well-behaved ebook: On Web Development.

(Or go straight to GitHub.)

In my book a website embeds all those third-party share and like and +1 scripts, whether from Facebook or from Twitter or from Google (or from AddThis) like this:

<div id=social></div>

That’s it *. The reason for this brevity is maintainability. Instead of contaminating tens or hundreds or thousands of files, template or not, WETting them with different scripts and their configuration code and such, we want to just add what is structurally needed. One container. To be populated and managed through one script.

Lacking alternatives, I’ve built such a script and now added it to GitHub. “Social Widget Wrapper” I’ve called it. (This can be renamed later.) It’s actually three scripts at the moment, for I’ve worked on three different approaches. (This should be consolidated.) And as it’s getting a bit more complicated from here, I suggest you check out the project page and, if you like, help me make all of it easier and better. I’m a terrible scripter †.

Oh. In other words, I’ve open-sourced a functioning but scrappy script, or three of those, that shield markup from social widgets or their scripts or so, and now throw it all at everyone around.

* …assuming an already existing site default script that takes care of the magic; otherwise we need to add another line for a script. Container and ID may be changed, sure (if appropriate).

† …which may affect the Google Photo Fetcher script, too.

Was this useful or interesting? Share (toot) this post, and support my work by learning with my ebooks!

About Me

Jens Oliver Meiert, on November 9, 2024.

I’m Jens (long: Jens Oliver Meiert), and I’m a frontend engineering leader and tech author/publisher. I’ve worked as a technical lead for companies like Google and as an engineering manager for companies like Miro, I’m a contributor to several web standards, and I write and review books for O’Reilly and Frontend Dogma.

I love trying things, not only in web development (and engineering management), but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (Please be critical, interpret charitably, and give feedback.)