diff --git a/client/galaxy/scripts/onload.js b/client/galaxy/scripts/onload.js
index 7ab257568f8..20822afc8f1 100644
--- a/client/galaxy/scripts/onload.js
+++ b/client/galaxy/scripts/onload.js
@@ -204,20 +204,23 @@ $(document).ready(() => {
}
function onloadWebhooks() {
- if (Galaxy.root !== undefined) {
- // Load all webhooks with the type 'onload'
- $.getJSON(`${Galaxy.root}api/webhooks/onload/all`, webhooks => {
- _.each(webhooks, webhook => {
- if (webhook.activate && webhook.script) {
- $("", { type: "text/javascript" })
- .text(webhook.script)
- .appendTo("head");
- $("", { type: "text/css" })
- .text(webhook.styles)
- .appendTo("head");
- }
+ // Wait until Galaxy.config is loaded.
+ if (Galaxy.config) {
+ if (Galaxy.config.enable_webhooks){
+ // Load all webhooks with the type 'onload'
+ $.getJSON(`${Galaxy.root}api/webhooks/onload/all`, webhooks => {
+ _.each(webhooks, webhook => {
+ if (webhook.activate && webhook.script) {
+ $("", { type: "text/javascript" })
+ .text(webhook.script)
+ .appendTo("head");
+ $("", { type: "text/css" })
+ .text(webhook.styles)
+ .appendTo("head");
+ }
+ });
});
- });
+ }
} else {
setTimeout(onloadWebhooks, 100);
}
diff --git a/lib/galaxy/webapps/galaxy/controllers/root.py b/lib/galaxy/webapps/galaxy/controllers/root.py
index 7dbb88015f5..dcf876cfb9f 100644
--- a/lib/galaxy/webapps/galaxy/controllers/root.py
+++ b/lib/galaxy/webapps/galaxy/controllers/root.py
@@ -52,6 +52,7 @@ class RootController(controller.JSAppLauncher, UsesAnnotations):
config = {
'active_view' : 'analysis',
'enable_cloud_launch' : app.config.get_bool('enable_cloud_launch', False),
+ 'enable_webhooks' : True if app.webhooks_registry.webhooks else False,
# TODO: next two should be redundant - why can't we build one from the other?
'toolbox' : app.toolbox.to_dict(trans, in_panel=False),
'toolbox_in_panel' : app.toolbox.to_dict(trans),