Files
gitbook/packages/react-math/src/KaTeXCSS.tsx
T
2025-02-26 17:59:34 +01:00

28 lines
571 B
TypeScript

'use client';
/**
* Dummy component to lazy load the KaTeX CSS.
*/
export default function KaTeXCSS() {
// Load the CSS as soon as possible (this is why we don't use an effect hook here)
// We lazy load the CSS to avoidNext bundling it in the main bundle
loadCSS();
return null;
}
let loaded = false;
function loadCSS() {
if (loaded || typeof window === 'undefined') {
return;
}
loaded = true;
// @ts-ignore
import('katex/dist/katex.min.css').then(() => {
document.body.classList.add('katex-loaded');
});
}