Fixed Docs JS error for Search on non-docs URLS

Words
103
Reading
1 min
Listen
Play
9y

Bug Fixes

  • JavaScript errors from embedded Algolia search JS was looking for a #docsearch element that was only on pages using the docs template. Any page being loaded was using the search JavaScript code and non docs pages would throw the console errors.

  • What was the solution?
    Check the page to see if the current page was in the /docs url structure, if so load the search JavaScript code, otherwise do nothing. This solves the issue on non-search pages no longer loading the JavaScript when it wasn't needed, and no longer throws the console errors.



Posted on Utopian.io - Rewarding Open Source Contributors

Fixed Docs JS error for Search on non-docs URLS | Ecency