⚡ Upgrade third party js logic improve load speed.
This commit is contained in:
16
assets/js/third-party/search/algolia.js
vendored
16
assets/js/third-party/search/algolia.js
vendored
@@ -1,12 +1,11 @@
|
||||
/* global instantsearch, algoliasearch, CONFIG, pjax */
|
||||
/* Algolia search engine */
|
||||
NexT.plugins.search.algolia = function() {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
const algoiajs = NexT.utils.getCDNResource(NexT.CONFIG.algolia.js);
|
||||
const algoliajs = NexT.utils.getCDNResource(NexT.CONFIG.algolia.js);
|
||||
const instantschjs = NexT.utils.getCDNResource(NexT.CONFIG.algolia.instantjs);
|
||||
|
||||
NexT.utils.getScript(algoiajs, {});
|
||||
NexT.utils.getScript(instantschjs, {}).then(() => {
|
||||
NexT.utils.getScript(algoliajs);
|
||||
NexT.utils.getScript(instantschjs, function() {
|
||||
|
||||
const { indexname, appid, apikey, hits } = NexT.CONFIG.algolia.cfg;
|
||||
const indexName = indexname;
|
||||
@@ -138,7 +137,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
onPopupClose();
|
||||
}
|
||||
});
|
||||
});;
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
6
assets/js/third-party/search/local.js
vendored
6
assets/js/third-party/search/local.js
vendored
@@ -1,4 +1,4 @@
|
||||
/* global CONFIG, pjax, LocalSearch */
|
||||
/* LocalSearch engine */
|
||||
class LocalSearch {
|
||||
constructor({
|
||||
path = '',
|
||||
@@ -227,7 +227,7 @@ class LocalSearch {
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
NexT.plugins.search.localsearch = function() {
|
||||
if (! NexT.CONFIG.localSearch.path) {
|
||||
// Search DB path
|
||||
console.warn('`search indexes file` is not configurate!');
|
||||
@@ -323,4 +323,4 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
onPopupClose();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user