File tree Expand file tree Collapse file tree 5 files changed +58
-5
lines changed
Expand file tree Collapse file tree 5 files changed +58
-5
lines changed Original file line number Diff line number Diff line change @@ -100,10 +100,19 @@ MathJax.loader.preLoad(
100100MathJax . config . startup . ready ( ) ;
101101
102102//
103- // Output the typeset page
103+ // Typeset the document
104104//
105105MathJax . typeset ( ) ;
106106const adaptor = MathJax . startup . adaptor ;
107107const html = MathJax . startup . document ;
108+
109+ //
110+ // If no math was found on the page, remove the stylesheet
111+ //
112+ if ( html . math . toArray ( ) . length === 0 ) adaptor . remove ( html . outputJax . chtmlStyles ) ;
113+
114+ //
115+ // Output the resulting HTML
116+ //
108117console . log ( adaptor . doctype ( html . document ) ) ;
109118console . log ( adaptor . outerHTML ( adaptor . root ( html . document ) ) ) ;
Original file line number Diff line number Diff line change @@ -105,10 +105,19 @@ MathJax.loader.preLoad(
105105MathJax . config . startup . ready ( ) ;
106106
107107//
108- // Output the typeset page
108+ // Typeset the document
109109//
110110MathJax . typeset ( ) ;
111111const adaptor = MathJax . startup . adaptor ;
112112const html = MathJax . startup . document ;
113+
114+ //
115+ // If no math was found on the page, remove the stylesheet
116+ //
117+ if ( html . math . toArray ( ) . length === 0 ) adaptor . remove ( html . outputJax . chtmlStyles ) ;
118+
119+ //
120+ // Output the resulting HTML
121+ //
113122console . log ( adaptor . doctype ( html . document ) ) ;
114123console . log ( adaptor . outerHTML ( adaptor . root ( html . document ) ) ) ;
Original file line number Diff line number Diff line change @@ -90,10 +90,23 @@ MathJax.loader.preLoad(
9090MathJax . config . startup . ready ( ) ;
9191
9292//
93- // Output the typeset page
93+ // Typeset the document
9494//
9595MathJax . typeset ( ) ;
9696const adaptor = MathJax . startup . adaptor ;
9797const html = MathJax . startup . document ;
98+
99+ //
100+ // If no math was found on the page, remove the stylesheet and font cache (if any)
101+ //
102+ if ( html . math . toArray ( ) . length === 0 ) {
103+ adaptor . remove ( html . outputJax . svgStyles ) ;
104+ const cache = adaptor . elementById ( adaptor . body ( html . document ) , 'MJX-SVG-global-cache' ) ;
105+ if ( cache ) adaptor . remove ( cache ) ;
106+ }
107+
108+ //
109+ // Output the resulting HTML
110+ //
98111console . log ( adaptor . doctype ( html . document ) ) ;
99112console . log ( adaptor . outerHTML ( adaptor . root ( html . document ) ) ) ;
Original file line number Diff line number Diff line change @@ -112,10 +112,19 @@ MathJax.loader.preLoad(
112112MathJax . config . startup . ready ( ) ;
113113
114114//
115- // Output the typeset page
115+ // Typeset the page
116116//
117117MathJax . typeset ( ) ;
118118const adaptor = MathJax . startup . adaptor ;
119119const html = MathJax . startup . document ;
120+
121+ //
122+ // If no math was found on the page, remove the stylesheet
123+ //
124+ if ( html . math . toArray ( ) . length === 0 ) adaptor . remove ( html . outputJax . chtmlStyles ) ;
125+
126+ //
127+ // Output the resulting HTML
128+ //
120129console . log ( adaptor . doctype ( html . document ) ) ;
121130console . log ( adaptor . outerHTML ( adaptor . root ( html . document ) ) ) ;
Original file line number Diff line number Diff line change @@ -114,10 +114,23 @@ MathJax.loader.preLoad(
114114MathJax . config . startup . ready ( ) ;
115115
116116//
117- // Output the typeset page
117+ // Typeset the document
118118//
119119MathJax . typeset ( ) ;
120120const adaptor = MathJax . startup . adaptor ;
121121const html = MathJax . startup . document ;
122+
123+ //
124+ // If no math was found on the page, remove the stylesheet and font cache (if any)
125+ //
126+ if ( html . math . toArray ( ) . length === 0 ) {
127+ adaptor . remove ( html . outputJax . svgStyles ) ;
128+ const cache = adaptor . elementById ( adaptor . body ( html . document ) , 'MJX-SVG-global-cache' ) ;
129+ if ( cache ) adaptor . remove ( cache ) ;
130+ }
131+
132+ //
133+ // Output the resulting HTML
134+ //
122135console . log ( adaptor . doctype ( html . document ) ) ;
123136console . log ( adaptor . outerHTML ( adaptor . root ( html . document ) ) ) ;
You can’t perform that action at this time.
0 commit comments