Vanilla JavaScript
Don’t want to use a framework? JamComments works with plain JavaScript too. See a live demo.
Why Use the Vanilla Client?
Section titled “Why Use the Vanilla Client?”Even without server-side rendering, this approach has advantages over other comment widgets:
- Minimal setup (~10 lines of code)
- No custom CSS to write
- Small footprint: ~2.6kb (gzipped) JavaScript + ~3.6kb (gzipped) HTML loaded on demand
Installation
Section titled “Installation”Option 1: npm
npm install @jam-comments/clientOption 2: CDN
<script src="https://unpkg.com/@jam-comments/client"></script>Basic Usage
Section titled “Basic Usage”With ES modules:
import { initialize } from "@jam-comments/client";
initialize("#comments-container", { path: window.location.pathname, apiKey: "your-api-key", domain: "your-site.com", environment: "production",});With CDN:
<script src="https://unpkg.com/@jam-comments/client"></script><script> JamComments.initialize("#comments-container", { path: window.location.pathname, apiKey: "your-api-key", domain: "your-site.com", environment: "production", });</script>The first argument is a CSS selector (like "#comments-container") or a direct reference to an HTML element (like document.getElementById('comments-container')). The comment form and any existing comments will be rendered inside this element.
Promise-Based API
Section titled “Promise-Based API”initialize() returns a Promise that resolves after the form is ready:
initialize("#comments", { path: window.location.pathname, apiKey: "your-api-key", domain: "your-site.com",}).then((element) => { // Form is now rendered and ready element.classList.add('is-loaded');});The promise resolves after the first repaint, so it’s safe to use for CSS animations:

Configuration Options
Section titled “Configuration Options”| Option | Required? | Description |
|---|---|---|
path | Yes | The page path for loading and saving comments |
domain | Yes | Your site’s domain (from account settings) |
apiKey | Yes | Your API key (from account settings) |
environment | Yes | ”production” or “development” |
dateFormat | No | Date format using PHP syntax. Default: “m/d/Y” |
Important Considerations
Section titled “Important Considerations”Loading comments client-side has trade-offs:
- Performance: The comment form loads after your page, which may cause a slight layout shift
- SEO: Search engines may not see the comments as easily as server-rendered content
For better performance and SEO, use a server-side integration if possible. The vanilla client is best for sites where you can’t run server-side code.