diff --git a/src/api/app/views/webui2/webui/comment/_content.html.haml b/src/api/app/views/webui2/webui/comment/_content.html.haml
index 5342759a079..627cb814cc6 100644
--- a/src/api/app/views/webui2/webui/comment/_content.html.haml
+++ b/src/api/app/views/webui2/webui/comment/_content.html.haml
@@ -18,8 +18,3 @@
- comment.children.each do |children|
= render partial: 'webui2/webui/comment/content', locals: { comment: children, commentable: commentable, level: level + 1 }
-:javascript
- $('#comments img').one('error', function(){
- $(this).after('');
- $(this).remove();
- });
diff --git a/src/api/app/views/webui2/webui/comment/_show.html.haml b/src/api/app/views/webui2/webui/comment/_show.html.haml
index 1a8e06b1cad..f8926afd13b 100644
--- a/src/api/app/views/webui2/webui/comment/_show.html.haml
+++ b/src/api/app/views/webui2/webui/comment/_show.html.haml
@@ -4,3 +4,11 @@
.comment_new
= render partial: 'webui2/webui/comment/new', locals: { commentable: commentable }
+
+:javascript
+ $(document).ready(function() {
+ $('#comments img').one('error', function() {
+ $(this).after('');
+ $(this).remove();
+ });
+ });