diff --git a/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js b/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js
index 22e9b2b9709f6e89d4046b88fbb6838b99178b57..071f21207c83a3f00426760f831b49041899c8dd 100644
--- a/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js
+++ b/app/assets/javascripts/behaviors/markdown/render_sandboxed_mermaid.js
@@ -155,7 +155,7 @@ function renderMermaids(els) {
         const alertContainer = document.createElement('div');
         alertContainer.classList.add(ALERT_CONTAINER_CLASS);
         alertContainer.classList.add('gl-mb-5');
-        parent.after(alertContainer);
+        parent.before(alertContainer);
         createAlert({
           message: __(
             'Warning: Displaying this diagram might cause performance issues on this page.',