Cloudinary Blog

Get Ready for Cloudinary’s Next- Generation JavaScript SDKs

Announcing the Next Generation Cloudinary JavaScript SDKs

Since its founding in 2012, Cloudinary has released software development kits (SDKs) in over a dozen languages and frameworks, adding feature after feature for numerous technologies. So far, those releases have proceeded in an evolutionary manner. We’re now overhauling them to serve developers even better, starting with the JavaScript (JS) SDK. For details, see our recent post on Cloudinary’s next-generation developer SDKs.

A New Dawn

While building SDKs, we always ask ourselves these three same questions:

  • What’s the right balance between abstraction and primitives?
  • How do we future-proof our internal features?
  • How do we future-proof the JavaScript (JS) technology stack and browser updates?

The answers are ever more important because, to meet the requirement of backwards compatibility, once the decisions are made and development proceeds, backtracking would be an astronomical task..

Hence, we’re brainstorming how to improve our entire stack of JS SDKs by modernizing our toolkit.

Even though the process is still in the early stage, we’d like to share with you our current thinking and solicit your feedback.

Our SDK Goals

We’re aiming for four goals for our new SDKs:

simplicity, enhanced semantics, smaller bundle size, and code reuse.

Simplicity More Desirable Than Flexibility

Instead of offering a jack-of-all-trades SDK, we’ll focus on ease of use, which matters the most to developers. Ease of use is different things to different people, however. To us, it means that you can read your code as easily as running it.

As flexible as our APIs are, that flexibility comes at the price of readability. Consider this snippet:

Copy to clipboard
tag = cl.image('sample.jpg', {
          crop: "scale",
          width: "auto:breakpoints",
        })

The current API accepts a map of configuration parameters, which, though easily extensible, are difficult to decipher in complex transformations.Plus, their seemingly unrelated properties (siblings) add to the confusion.

We propose the following instead for much-improved readability in output along with grouping of relevant properties:

Copy to clipboard
Let img = New TransformableImage('sample.jpg')
    .addAction(scale().width('auto'))

In the current SDK, the relativity of the scale and width properties above is hidden. The new syntax clearly shows that they are related.

Furthermore, we plan to use types behind the scenes since all modern IDEs feature the much desired auto-completion capability.

Semantics As a First-Class Citizen

For optimum flexibility, the Cloudinary URL represents an expression, not functionality. The current SDK syntax bridges the functionality gap but falls short by merely renaming arguments and making them more accessible. Also lacking is an in-depth understanding of how the properties, such as scale and width interact.

As a contrast, the new SDK syntax takes semantics seriously. We’ll define all the operations that are performed on assets as actions, e.g., resizing, scaling, and adjusting assets. Along with proper namespaces, enhanced semantics translates to a superb developer experience, enabling you to discover features much more readily.

Minimum Bundle Size Through Tree Shaking

The large footprint of the SDK has long been a sour point at Cloudinary. As more features are added, the SDK bundle size correspondingly grows. Additionally, the current SDK is one-size-fits-all. Even if you use only a small subset of its features, you must download the entire package.

The new SDK will be ESM (ES Module) friendly, complete with full support for tree-shaking. That is, you bundle only what you use and throw away the rest.

Also, in the works are new plugins you can install instead of having to incorporate them in the main bundle. See this example:

Copy to clipboard
Import * as Resize, {scale, resize, /* and more */  } from @cloudinary/resize

Share Functionality Across SDKs

Since our SDKs were not developed in unison, some features exist in multiple versions but with slight variations. For consistency and uniformity, we’ll unify all the code into shared libraries to support an ever-growing array of frameworks. That’s the right formula for proper growth!

The Endgame

For all that the above goals won’t be easy to achieve, we’re committed to delivering the best developer experience possible. After all, coding should be a delight, not a chore.

Our code has been open source from Day One so feel free to track its progress on GitHub.Above all, send us your thoughts.

We’ll be back soon with more updates.

The Cloudinary SDK team

Recent Blog Posts

Top Five Web-Video Formats of 2021

By William Imoh
The Five Most Popular Web-Video Formats and Streaming Protocols

Over the past 15 years, the video industry has undergone a significant change in video formats on the web. In particular, in the early 2010s, the 3GP format, which the 3rd Generation Partnership Project (3GPP) created for 3G-enabled mobile devices, went nearly extinct. The advancement of mobile devices and cellular networks has brought about the need for pioneers to build better formats for a faster user experience.

Read more
Cloudinary Introduces Integration With SAP Commerce Cloud

We’re excited to announce Cloudinary’s integration with SAP Commerce Cloud, through which the latter’s customers can significantly boost the visual media experience on their website or app.

SAP Commerce Cloud powers some of the largest e-commerce sites (B2C, B2B, and B2B2C businesses), complete with building blocks like storefront design and order management. Reinforced with Cloudinary’s laser-sharp focus on optimizing, managing, and delivering images and videos, the new extension will enable SAP Commerce Cloud customers to create unique and engaging visual experiences effortlessly.

Read more
Personalizing Video Email for Marketing Campaigns With Cloudinary

As critical as it is to engage with shoppers in order to succeed in e-commerce, old-style, boring emails are far from being effective. In fact, they tend to be annoying because no one likes to read formulaic, generic messages that are sent en masse. For better results, rethink your email marketing campaigns and try out creative strategies.

Read more
Muted Videos and Subtitles

The bane of our existence is the lack of efficient ways for tackling the plethora of recurring tasks in our lives. One of those tasks is surfing the internet. We consume a lot of web content daily, of which a large percentage are images and videos. We’re constantly quickly scrolling through 30-second videos or checking out pictures of cute items we’d like to buy in our free time.

Read more

Building a Roommate-Matching App With Cloudinary and Jamstack

By Marcelo Ricardo de Oliveira
Building a Roommate-Matching App With Cloudinary and Jamstack

Roommate matching can be a pain—especially during the COVID pandemic when people don't want to meet in person. Matching apps like Flatmates, Roomster, and roommates.com are helpful, and if you're in the roommate-matching space, you know that great video is essential for those seeking roommates. Fortunately, Cloudinary can help.

Read more