npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@sleekcms/ajaxed-forms

v1.1.0

Published

A lightweight JavaScript library that converts static HTML forms into AJAX-enabled forms for SleekCMS. Simply add a data-sleekcms attribute to your form and this script handles the rest.

Downloads

92

Readme

ajaxed-forms

CI Tests npm version

A lightweight JavaScript library that converts static HTML forms into AJAX-enabled forms. Built for SleekCMS but will work for any endpoint. Simply add a data-sleekcms attribute to your form and this script handles the rest.

Features

  • 🚀 Zero dependencies
  • 📦 Tiny footprint (~2KB)
  • 🔄 Automatic AJAX form submission
  • 🎯 Dynamic form detection with MutationObserver
  • ✅ Success/error message display
  • 🔒 Works with SleekCMS form endpoints
  • 🧪 100% test coverage

Installation

Via CDN

Include the script in your HTML:

<!-- unpkg -->
<script src="https://unpkg.com/@sleekcms/ajaxed-forms"></script>

<!-- jsDelivr -->
<script src="https://cdn.jsdelivr.net/npm/@sleekcms/ajaxed-forms"></script>

Via npm

npm install @sleekcms/ajaxed-forms

Then import in your JavaScript:

import '@sleekcms/ajaxed-forms';

Usage

Basic Usage

Add the data-sleekcms attribute to your form with your SleekCMS form ID:

<form data-sleekcms="myform-abc123">
  <input type="text" name="name" placeholder="Your name" required />
  <input type="email" name="email" placeholder="Your email" required />
  <button type="submit">Submit</button>
</form>

<script src="https://unpkg.com/@sleekcms/ajaxed-forms"></script>

Custom Action URL

You can specify a custom action URL using the action or data-action attribute:

<form data-sleekcms="true" action="https://example.com/custom-endpoint">
  <input type="text" name="message" />
  <button type="submit">Send</button>
</form>

SleekCMS Form ID Format

The data-sleekcms attribute accepts a form ID in the format formname-uniqueid (e.g., contact-abc123). The script automatically constructs the SleekCMS endpoint:

https://form.sleekcms.com/[your-form-id]

How It Works

  1. The script detects all forms with the data-sleekcms attribute
  2. Automatically intercepts form submission and prevents default behavior
  3. Submits form data via AJAX using the Fetch API
  4. Displays submission status (success/error) below the form
  5. Resets the form on successful submission
  6. Watches for dynamically added forms using MutationObserver

Browser Support

  • Modern browsers with Fetch API support
  • Chrome, Firefox, Safari, Edge (latest versions)
  • Gracefully degrades in older browsers with a console warning

Development

Setup

npm install

Running Tests

# Run tests once
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

Test Coverage

The library has comprehensive test coverage including:

  • Form detection and initialization
  • Dynamic form detection with MutationObserver
  • Successful and failed form submissions
  • Network error handling
  • Multiple action URL configurations
  • Edge cases and browser compatibility

Current coverage: 100% statements, 100% functions, 100% lines, 94.44% branches

API

Form Attributes

  • data-sleekcms: Required. Either a form ID (e.g., contact-abc123) or "true" when using custom action URLs
  • action or data-action: Optional. Custom endpoint URL for form submission
  • method: Optional. HTTP method (defaults to POST)

Response Format

The script handles both JSON and plain text responses:

JSON Response:

{
  "message": "Form submitted successfully!"
}

Plain Text Response:

Thank you for your submission!

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.