Skip to content

Commit 7aa7bca

Browse files
committed
Refactor SimpleJekyllSearch
Remove jquery dependency.
1 parent 1a0d4d9 commit 7aa7bca

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

documentation/index.html

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,22 @@ <h1 class="color-gray-800 weight-700">{% t titles.documentation %}</h1>
3333
</div>
3434

3535
<script>
36-
$(document).ready(function() {
37-
var sjs = SimpleJekyllSearch({
36+
const initSearch = () => {
37+
SimpleJekyllSearch({
3838
searchInput: document.getElementById('search-input'),
3939
resultsContainer: document.getElementById('results-container'),
4040
noResultsText: "{% t documentation.general.no-results %} :(",
4141
searchResultTemplate: '<li><a href="{url}">{title}</a></li>',
4242
limit: 5,
4343
fuzzy: false,
4444
json: '{% if site.lang != "en" %}/{{ site.lang }}{% endif %}/assets/datasets/documentation_index.json'
45-
})
46-
});
45+
});
46+
};
47+
if('loading' === document.readyState) {
48+
// Loading hasn't finished yet.
49+
document.addEventListener('DOMContentLoaded', initSearch)
50+
} else {
51+
// `DOMContentLoaded` has already fired.
52+
initSearch()
53+
}
4754
</script>

0 commit comments

Comments
 (0)