diff --git a/templates/body_bottom.html b/templates/body_bottom.html index 1f55d42..8f7f8fb 100644 --- a/templates/body_bottom.html +++ b/templates/body_bottom.html @@ -1,9 +1,19 @@ -{% if static.scripts.bootstrap %} +{% if static.scripts | length >= 1 +%} + + + + {% for _, script in static.scripts | items %} + {# Load scripts at the bottom by default #} + {% if not script.place_in_head | default(False) %} + + {% endif %} + {% endfor %} {% endif %} + diff --git a/templates/header.html b/templates/header.html index c410704..f9aa50f 100644 --- a/templates/header.html +++ b/templates/header.html @@ -48,12 +48,24 @@ data-bs-theme="{{ css_theme_name | default('auto') }}" > - {% if static.scripts.theme %} + + {# Scripts that should be loaded first to avoid flickering (theme, etc) #} + {% if static.scripts | length >= 1 %} + + + + {% for _, script in static.scripts | items %} + {# Only load script if it should be in the head #} + {% if script.place_in_head | default(False) %} + + + {% endif %} + {% endfor %} {% endif %} @@ -92,31 +104,19 @@ --> - {% if static.css.bootstrap %} - - {% endif %} + {% if static.css | length >= 1 +%} - {% if static.css.theme %} - - {% endif %} + - {% if static.css.icons %} + {% for _, style in static.css | items %} - {% endif %} + + {% endfor %} + {% endif %} diff --git a/test.py b/test.py index f0da63c..5029230 100644 --- a/test.py +++ b/test.py @@ -21,7 +21,7 @@ template_vars = { "bootstrap": { "src": "./templates/static/bootstrap.bundle.min.js", }, - "theme": {"src": "./templates/static/color-modes.js"}, + "theme": {"src": "./templates/static/color-modes.js", "place_in_head": True}, }, "css": { "bootstrap": {"src": "./templates/static/bootstrap.min.css"},