From 7da1b43f2bcdcdfa70a2e581c859801fb35874da Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 27 Jan 2021 14:32:00 -0500 Subject: [PATCH] fix: script failure if client-side page script does not exist --- public/src/ajaxify.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/src/ajaxify.js b/public/src/ajaxify.js index d38bab6d71..f19742f010 100644 --- a/public/src/ajaxify.js +++ b/public/src/ajaxify.js @@ -320,14 +320,17 @@ ajaxify = window.ajaxify || {}; location = ''; } - require(['hooks', location + tpl_url], (hooks, module) => { + const proceed = (hooks, module) => { if (module && module.init) { module.init(); } hooks.fire('static:script.init', { tpl_url }).then(ajaxify.loadExtraScripts.bind(null, tpl_url, callback)); - }, function () { - // ignore 404 error + }; + + require(['hooks', location + tpl_url], proceed, () => { + // Module doesn't exist or didn't load, proceed without it + require(['hooks'], proceed); }); };