From e7bdfb35d3f97a1ef81bd39f4d2aa2b52032bba7 Mon Sep 17 00:00:00 2001 From: Dan Allen Date: Sun, 2 Sep 2018 18:01:07 -0600 Subject: [PATCH] further defer loading of docsearch --- src/js/vendor/docsearch.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/js/vendor/docsearch.js b/src/js/vendor/docsearch.js index 9f363d3..a86a1cc 100644 --- a/src/js/vendor/docsearch.js +++ b/src/js/vendor/docsearch.js @@ -1,15 +1,17 @@ ;(function () { var docsearch = require('docsearch.js/dist/cdn/docsearch.js') - var config = document.getElementById('search-script').dataset - var style = document.createElement('style') - style.innerText = '@import "' + config.stylesheet + '"' - document.body.appendChild(style) - docsearch({ - appId: config.appId, - apiKey: config.apiKey, - indexName: config.indexName, - inputSelector: '#search-query', - algoliaOptions: { hitsPerPage: 25 }, - debug: false, - }) + window.setTimeout(function () { + var config = document.getElementById('search-script').dataset + var style = document.createElement('style') + style.innerText = '@import "' + config.stylesheet + '"' + document.head.appendChild(style) + docsearch({ + appId: config.appId, + apiKey: config.apiKey, + indexName: config.indexName, + inputSelector: '#search-query', + algoliaOptions: { hitsPerPage: 25 }, + debug: false, + }) + }, 1000) })()