Announcing Cart.js
This week marks the first “official” release of an open source project I’ve been working on for some time. It’s Cart.js, and it’s designed to make the addition of Ajax cart features to Shopify themes super-simple.
Ajax cart functionality is very common on eCommerce stores these days - it can provide a much smoother experience for customers, and gets products in to their cart faster.
Shopify provides Ajax endpoints for cart manipulation (adding, removing and updating items, managing cart attributes, et cetera), but the existing libraries used to interact with those endpoints have a few issues.
Ajax calls need to be made synchronously, the API is a bit inconsistent, and there’s no provision for updating your DOM on the basis of changes to the cart.
Cart.js is the culmination of my work implementing these features across a number of client themes, and provides:
- A simple, consistent API for cart manipulation;
- A Data API for markup-only use without needing to write a line of Javascript;
- A DOM Binding modules to dynamically render HTML templates as your cart changes.
As an open-source project, Cart.js is actively seeking feedback and contributions from the community, so if it sounds like you might be able to make use of it, please head over to the Cart.js homepage!