Commits

Georg Brandl committed 423faa0

#322: Improve responsiveness of search page by loading the search index asynchronously.

Comments (0)

Files changed (2)

sphinx/themes/basic/search.html

 {% extends "layout.html" %}
 {% set title = _('Search') %}
 {% set script_files = script_files + ['_static/searchtools.js'] %}
+{% block extrahead %}
+  <script type="text/javascript">
+    jQuery(function() { Search.loadIndex("{{ pathto('searchindex.js', 1) }}"); });
+  </script>
+  {{ super() }}
+{% endblock %}
 {% block body %}
   <h1 id="search-documentation">{{ _('Search') }}</h1>
   <div id="fallback" class="admonition warning">
   {% endif %}
   </div>
 {% endblock %}
-{% block footer %}
-  {{ super() }}
-  <script type="text/javascript" src="{{ pathto('searchindex.js', 1) }}"></script>
-{% endblock %}

sphinx/themes/basic/static/searchtools.js

       }
   },
 
-  /**
-   * Sets the index
-   */
+  loadIndex : function(url) {
+    $.ajax({type: "GET", url: url, data: null, success: null,
+            dataType: "script", cache: true});
+  },
+
   setIndex : function(index) {
     var q;
     this._index = index;