Skip to content

Commit

Permalink
Defer all the JS scripts
Browse files Browse the repository at this point in the history
Signed-off-by: Pradyun Gedam <pradyunsg@users.noreply.github.com>
  • Loading branch information
pradyunsg committed Nov 14, 2020
1 parent b7ad0db commit e8dc65a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions src/furo/theme/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,19 @@
{# Custom JS #}
{%- block regular_scripts -%}
{# This is *exactly* how `basic` handles this file. #}
<script id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
{%- for path in script_files -%}
{{ js_tag(path) }}
<script defer id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
{% for path in script_files -%}
{% set tag = js_tag(path) -%}
{%- if tag.startswith("<script ") -%}
{%- set tag = tag[:7] + " defer" + tag[7:] -%}
{%- endif -%}
{{ tag }}
{% endfor -%}
{%- endblock regular_scripts -%}

{# Theme-related JavaScript code #}
{%- block theme_scripts -%}
<script src="{{ pathto('_static/scripts/main.js', 1) }}?state={{ furo_asset_hash }}"></script>
<script defer src="{{ pathto('_static/scripts/main.js', 1) }}?state={{ furo_asset_hash }}"></script>
{%- endblock -%}

{%- endblock scripts -%}
Expand Down
2 changes: 1 addition & 1 deletion src/furo/theme/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{%- block extrajs -%}
{{ super() }}
<script src="{{ pathto('_static/searchtools.js', 1) }}" defer></script>
<script defer src="{{ pathto('_static/searchtools.js', 1) }}"></script>
{%- endblock extrajs-%}

{%- block htmltitle -%}
Expand Down

0 comments on commit e8dc65a

Please sign in to comment.