emgithub icon indicating copy to clipboard operation
emgithub copied to clipboard

Multiple `<script>` tags loaded for highlightjs

Open 9oelM opened this issue 1 year ago • 0 comments

In this part of the code:

https://github.com/yusanshi/emgithub/blob/684c4445e80cb5255ee7af68bb1e463c1f44c3ed/embed-v2.js#L340-L342

We check if the global variable hljs is present. If not, we load the script. But it seems that if we load multiple code snippets fast enough, hljs will be undefined while they are being loaded, causing multiple <script> tags to appear to load highlightjs.

It can be seen on my website:

image

This issue may or may not appear depending on the internet connectivity. But it is there. To mitigate this issue, I suggest that we check the existence of the script tag loading highlighjs library instead of checking hljs variable.

9oelM avatar Apr 15 '24 14:04 9oelM