diff --git a/templates/pages/backoffice/ajaxpage/layout.html.twig b/templates/pages/backoffice/ajaxpage/layout.html.twig index 069479a5b..10f0f6fbb 100644 --- a/templates/pages/backoffice/ajaxpage/layout.html.twig +++ b/templates/pages/backoffice/ajaxpage/layout.html.twig @@ -70,7 +70,7 @@ * ``` */ - // If these constants aren't defined by the main page, define them (global) ourselves + // If these constants aren't defined by the main page, define them (global) ourselves if (typeof aLoadedJsFilesRegister === "undefined") { Object.defineProperty(window, "aLoadedJsFilesRegister", { value: new Map(), @@ -186,11 +186,25 @@ {% endif %} {% block iboPageCssFiles %} - {% for aCssFileData in aPage.aCssFiles %} - - {% endfor %} + {% endblock %} {{ aPage.sCapturedOutput|raw }} diff --git a/templates/pages/backoffice/webpage/layout.html.twig b/templates/pages/backoffice/webpage/layout.html.twig index 983a32a55..79d2fab66 100644 --- a/templates/pages/backoffice/webpage/layout.html.twig +++ b/templates/pages/backoffice/webpage/layout.html.twig @@ -24,8 +24,9 @@ - jQuery scripts spurious problems (like failing on a 'reload') #} {% block iboPageCssFiles %} {% for aCssFileData in aPage.aCssFiles %} + {# Mind that CSS files are registered in a JS variable below (@see aLoadedCssFilesRegister), to ensure that a file isn't loaded twice through an async call #} {% if aCssFileData['condition'] != '' %}{% endif %} {% endfor %} {% endblock %} @@ -66,11 +67,26 @@ {% block iboPageTemplates %} {% endblock %} +{# CSS files can either be loaded initially or requested by an XHR response #} +{# In order to ensure that a file isn't loaded twice, we register them here so async calls can check if they to load their dependencies or not #} +{# Note that unlike for the JS files, we don't need to use promises, as we don't need them to wait for the previous one to be loaded #} +{# (Having a CSS loaded again can lead to rule overloads being reverted) #} + {# JS files can either be loaded initially or requested by an XHR response #} {# - For the initial page, all files are loaded before running inline snippets #} {# - For XHR responses, we need to ensure that all required files are fully loaded before running inline snippets #} - +