How a Crowdsourced Code Snippet Library Can Boost Your Open Source Project

Roughly one year ago this month Pippin Williamson made the first commit to Easy Digital Download’s “Library” repository on GitHub. He created the library to be a community-maintained repository of code snippets that modify the default behavior of Easy Digital Downloads.

So far the library has received 113 commits from eight contributors, which has resulted in more than sixty code snippets available to users and developers. The snippets cover everything from modifying the checkout experience to customizing the plugin’s email notifications.

With more than half a million downloads on WordPress.org and 150+ free and commercial extensions, Easy Digital Downloads has a large community of developers who work with the software every day.

Williamson said that having the ability to share snippets for modifying EDD behavior has been hugely useful for the project. He only approves solid, tested code but in most cases the snippets have been submitted by the EDD team. Managing the repository hardly costs any time at all, “a few minutes per week at max,” he said.

The benefits of hosting a community-maintained repository of code snippets far outweigh the minimal time required to maintain it. “The biggest problem it has is humans: we tend to forget to put snippets up a lot of times,” Williamson said. He identified three key areas where the library benefits the project:

It’s a resource for the support team.

It’s a source of examples for people wanting to customize behavior.

It provides live testing (similar to add-on plugins) for potential features to add to core.

The most common way that snippets are added to the EDD library is through the support staff. “We write code snippets for customers while helping with support tickets and then we put the snippet in the library,” Williamson said.

He hasn’t seen any WordPress-based open source projects or products doing anything similar but thinks that others could gain some value from implementing a library. GenerateWP might be the closest example of a site attempting something similar for snippets that extend WordPress core, with its new user code library feature. However, this doesn’t have the collaborative benefits of hosting the library on GitHub.

Larger WordPress projects like the Pods Framework, Gravity Forms, WooCommerce, BuddyPress, Jetpack, etc., are prime candidates that might benefit from a library of tested snippets. Of course, it helps that the base EDD plugin is free and open source. A 100% commercial project may not fare as well with a crowdsourced snippet library.

Easy Digital Download is well known for being extensible and developer-friendly. Over the past two years Williamson built a community of contributors 120+ strong and found that extensibility has a direct correlation to profitability. The code snippet library is undoubtedly a valuable investment toward helping developers extend the base EDD plugin.

Could your open source project or product benefit from a community-maintained library of code snippets? A snippet library can keep developers from having to reinvent the wheel when performing common modifications. It also provides a tested resource of code samples for those who are just getting started extending your project. If Williamson’s experience is any proof, then the few minutes per week spent on a snippets library can pay off with a big boost for the community surrounding your project.