Skip to content

Commit

Permalink
themes: use noscript for search js notification
Browse files Browse the repository at this point in the history
The "search.html" template will generate a warning admonition about
requiring JavaScript for search and automatically hiding the element
when supported. While functional, if a client renders the page slowly,
the warning notification may be visible to the user for a moment.

Instead of relying on JavaScript to suppress this warning, use a
`noscript` tag to hide the warning for clients who do not support
JavaScript. This also has the benefit of one less JavaScript call
required by a client.

Signed-off-by: James Knight <james.d.knight@live.com>
  • Loading branch information
jdknight authored and tk0miya committed Sep 11, 2021
1 parent 293beec commit e01d914
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sphinx/themes/basic/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
{% block body %}
<h1 id="search-documentation">{{ _('Search') }}</h1>
{% block scriptwarning %}
<div id="fallback" class="admonition warning">
<script>$('#fallback').hide();</script>
<noscript>
<div class="admonition warning">
<p>
{% trans %}Please activate JavaScript to enable the search
functionality.{% endtrans %}
</p>
</div>
</noscript>
{% endblock %}
{% block searchtext %}
<p>
Expand Down

0 comments on commit e01d914

Please sign in to comment.