Web Component
You can embed JamComments using a standard web component. This works in any HTML page, no build step required.
Quick Start
Section titled “Quick Start”Load the script and add the <jam-comments> element to your page:
<script src="https://unpkg.com/@jam-comments/component"></script>
<jam-comments data-api-key="123|your-api-key"></jam-comments>Configuration
Section titled “Configuration”Required
Section titled “Required”data-api-key— Your API key from account settings
Optional
Section titled “Optional”| Attribute | Description | Default |
|---|---|---|
data-domain | Your site’s domain | Current page’s domain |
data-path | The page path | Current page’s path |
data-environment | ”production” or “development" | "production” |
data-date-format | How to format dates (PHP format) | “m/d/Y” |
data-initialized-callback | JavaScript function to call when ready | — |
Example with All Options
Section titled “Example with All Options”<script> window.onCommentsReady = () => console.log("Comments loaded!");</script>
<jam-comments data-api-key="123|your-api-key" data-domain="your-site.com" data-path="/blog/my-post" data-environment="production" data-date-format="F j, Y" data-initialized-callback="window.onCommentsReady"></jam-comments>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 web component is best for sites where you can’t run server-side code or need a quick drop-in solution.