Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No icons are rendered in plain HTML file #54

Closed
benoit74 opened this issue May 6, 2024 · 1 comment
Closed

No icons are rendered in plain HTML file #54

benoit74 opened this issue May 6, 2024 · 1 comment

Comments

@benoit74
Copy link

benoit74 commented May 6, 2024

I already had a look at #31 and many other issues.

I still struggle to make jdenticon work in many situations, at least it is very unstable (simply refreshing the page might make the icon appear or disappear).

Sample HTML:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta content="utf-8" http-equiv="encoding">
    <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="./jdenticon.js"></script>
    <script src="./i_am_missing.js"></script>
</head>

<body>
    jdenticon
    <svg width="80" height="80" data-jdenticon-value="Bob"></svg>

</body>

</html>
  • HTML is placed in a file named index.html
  • jdenticon.js is downloaded from https://raw.githubusercontent.com/dmester/jdenticon/3.2.0/dist/jdenticon.js and placed in same folder as index.html
  • i_am_missing.js is an intentionally missing file (this is not the only condition which leads to icon not being rendered, but it seems to be a good repro case)
  • everything is served with python -m http.server (with Python 3.12, but I have experienced the issue first with another server, so it is probably not relevant; it is however mandatory to use a webserver to see the issue)

Same test case is available online: http://www.oviles.info/jdenticon/ (with a different server, not sure what is used by the hosting provider currently)

Browser tested : Firefox 125.0.3 + Safari 17.1 + Chrome 124.0.6367.92 on Mac OS 12.7.4

@dmester
Copy link
Owner

dmester commented May 10, 2024

Thanks for reporting this issue. Jdenticon used setTimeout for scheduling the initial icon rendering. This does not seem enough when the library is included in <head>.

The initial rendering has now been moved to DOMContentLoaded to make it more likely that the page is loaded when the icons are rendered.

The fix is included in Jdenticon 3.3.0.

Note:
If icon placeholders are added dynamically using JavaScript, it is recommended not relying on the automatic rendering, and instead call any of the update methods when an icon has been inserted or modified.

@dmester dmester closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants