src/pydata_sphinx_theme/assets/scripts/mixin.js
raw| 1 | /* define several functions to replace jQuery methods |
| 2 | * inspired by https://tobiasahlin.com/blog/move-from-jquery-to-vanilla-javascript/ |
| 3 | */ |
| 4 | |
| 5 | /** |
| 6 | * Execute a method if DOM has finished loading |
| 7 | * |
| 8 | * @param {function} callback the method to execute |
| 9 | */ |
| 10 | export function documentReady(callback) { |
| 11 | if (document.readyState != "loading") callback(); |
| 12 | else document.addEventListener("DOMContentLoaded", callback); |
| 13 | } |