diff --git a/layouts/partials/script_async.html b/layouts/partials/script_async.html
index 578dfcf..c1c59cc 100644
--- a/layouts/partials/script_async.html
+++ b/layouts/partials/script_async.html
@@ -1,2 +1,2 @@
{{ $script := resources.Get . | minify | fingerprint }}
-
+
diff --git a/static/src/js/index.js b/static/src/js/index.js
index 1a3519d..7c6b7f8 100644
--- a/static/src/js/index.js
+++ b/static/src/js/index.js
@@ -2,6 +2,16 @@
var Clipboard = require('clipboard');
+function waitFor(global, callback) {
+ // Wait for a property to exist on window before runnig callback
+ var intervalId = setInterval(function () {
+ if (window[global]) {
+ clearInterval(intervalId);
+ callback();
+ }
+ }, 100);
+}
+
$('.image').each(function () { // setup div-image hybrids
var ele = $(this);
@@ -32,9 +42,12 @@ $(document).ready(function () {
}
});
- mermaid.initialize({
- startOnLoad: true
+ waitFor('mermaid', function () {
+ mermaid.initialize({
+ startOnLoad: true
+ });
});
+
});
$('.navbar-brand').on('click', function (event) {