Skip to content

Web Component

You can embed JamComments using a standard web component. This works in any HTML page, no build step required.

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>
AttributeDescriptionDefault
data-domainYour site’s domainCurrent page’s domain
data-pathThe page pathCurrent page’s path
data-environment”production” or “development""production”
data-date-formatHow to format dates (PHP format)“m/d/Y”
data-initialized-callbackJavaScript function to call when ready
<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>

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.