FIX: don't do any work if not enabled

FIX: don’t do any work if not enabled

diff --git a/assets/javascripts/initializers/discourse-graphviz.js.es6 b/assets/javascripts/initializers/discourse-graphviz.js.es6
index c24d616..2b10694 100644
--- a/assets/javascripts/initializers/discourse-graphviz.js.es6
+++ b/assets/javascripts/initializers/discourse-graphviz.js.es6
@@ -38,12 +38,12 @@ export default {
     withPluginApi("0.8.22", api => {
       api.decorateCooked(
         $elem => {
-          const $graphviz = $elem.find(".graphviz");
+          if (!Discourse.SiteSettings.discourse_graphviz_enabled) {
+            return;
+          }
 
-          if (
-            $graphviz.length &&
-            Discourse.SiteSettings.discourse_graphviz_enabled
-          ) {
+          const $graphviz = $elem.find(".graphviz");
+          if ($graphviz.length) {
             $graphviz.each((_, nodeContainer) => {
               const $container = $(nodeContainer);

GitHub sha: 468ae2fe

1 Like