JavaScript API

Below is the Jdenticon interface described. In most cases the HTML attributes are enough for using Jdenticon. Check them out before reading the rest of the API.

Html attributes

Attributedata-jdenticon-valueSpecified on a <canvas> or <svg> element to declare that an identicon should be rendered for this value within the element.
Attributedata-jdenticon-hashSpecified on a <canvas> or <svg> element to declare that an identicon should be rendered for this hexadecimal hash string within the element.

Properties

Propertyjdenticon.configConfigures the appearance of generated icons and the behavior of Jdenticon.

Methods

Methodjdenticon()Updates all <canvas> or <svg> elements with the data-jdenticon-value or data-jdenticon-hash attribute.
Methodjdenticon.update()Updates the identicon in a specific DOM element or for all elements matching a CSS selector.
Methodjdenticon.drawIcon()Renders an indenticon on a HTML canvas.
Methodjdenticon.toPng()Renders an identicon as a PNG image. Not available in the browser.
Methodjdenticon.toSvg()Renders an identicon as a SVG image.
Method$.fn.jdenticon()jQuery wrapper plugin for updating all identicons in a query element collection.

Troubleshooting

A common problem is that no icons are rendered. Try one of the solutions in this article to solve the problem.