1- import { useState , useCallback , useMemo } from 'react' ;
1+ import { useState , useCallback , lazy , Suspense } from 'react' ;
22import Box from '@mui/material/Box' ;
33import Tabs from '@mui/material/Tabs' ;
44import Tab from '@mui/material/Tab' ;
@@ -15,11 +15,8 @@ import ContentCopyIcon from '@mui/icons-material/ContentCopy';
1515import CheckIcon from '@mui/icons-material/Check' ;
1616import ExpandMoreIcon from '@mui/icons-material/ExpandMore' ;
1717import ExpandLessIcon from '@mui/icons-material/ExpandLess' ;
18- import SyntaxHighlighter from 'react-syntax-highlighter/dist/esm/prism-light' ;
19- import { oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism' ;
20- import python from 'react-syntax-highlighter/dist/esm/languages/prism/python' ;
2118
22- SyntaxHighlighter . registerLanguage ( 'python' , python ) ;
19+ const CodeHighlighter = lazy ( ( ) => import ( './CodeHighlighter' ) ) ;
2320
2421// Map tag category names to URL parameter names
2522const SPEC_TAG_PARAM_MAP : Record < string , string > = {
@@ -217,24 +214,16 @@ export function SpecTabs({
217214 }
218215 } ;
219216
220- // Memoize syntax-highlighted code
221- const highlightedCode = useMemo ( ( ) => {
222- if ( ! code ) return null ;
223- return (
224- < SyntaxHighlighter
225- language = "python"
226- style = { oneLight }
227- customStyle = { {
228- margin : 0 ,
229- fontSize : '0.85rem' ,
230- fontFamily : '"MonoLisa", "MonoLisa Fallback", monospace' ,
231- background : 'transparent' ,
232- } }
233- >
217+ // Lazy-loaded syntax highlighter - only loads when Code tab is opened
218+ const highlightedCode = code ? (
219+ < Suspense fallback = {
220+ < Box sx = { { fontFamily : '"MonoLisa", "MonoLisa Fallback", monospace' , fontSize : '0.85rem' , whiteSpace : 'pre-wrap' , color : '#4b5563' } } >
234221 { code }
235- </ SyntaxHighlighter >
236- ) ;
237- } , [ code ] ) ;
222+ </ Box >
223+ } >
224+ < CodeHighlighter code = { code } />
225+ </ Suspense >
226+ ) : null ;
238227
239228 // Format date
240229 const formatDate = ( dateStr ?: string ) => {
0 commit comments