找回密码
 快速注册
搜索
查看: 366|回复: 6

lazyload mathjax

[复制链接]

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

hbghlyj 发表于 2022-1-13 04:26 |阅读模式
本帖最后由 hbghlyj 于 2022-1-13 04:40 编辑 懒加载: 延迟加载图片,达到加载条件时再加载。 作用:减轻服务器压力,节约流量,页面加载速度快。
            例如Discuz中帖子内对图片附件懒加载
92325435-5b350100-f07d-11ea-97b1-e9c5b815d54a[1].png
预加载:提前加载图片,当用户需要查看时是直接从浏览器缓存里取的资源,用户操作体验速度快。
           原理:在浏览器加载页面时创建image对象并赋值src链接作用:让用户有快速的冲浪体验。
类似于图片的懒加载,对于数学公式的mathjax排版也可以懒加载,使页面加载速度更快,这对于长达数屏甚至数十屏的页面非常有用,见
mathjax的issue
github.com/mathjax/MathJax/issues/419
mathjax-lazyload的github项目
github.com/Dashed/mathjax-lazyload

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-1-13 04:45
不同浏览器上的mathjax性能对比:
Remarks on speed
A simple test indicates that the output rendering speed varies greatly across platforms.

For example, on a 2011 macbook pro, rendering (no downloads, everything cached) of en.wikipedia.org/wiki/Matrix_multiplication

Chrome: html: ~2500ms, svg:~1850ms
Safari: html: ~1450ms, svg:~1000ms, mathml: ~300ms
Firefox: html: ~3300ms, svg:~2400ms, mathml:~880ms
Disabling the measurements that HTML needs but SVG doesn't, brings HTML output up to SVG speed (but comes at the cost of rendering quality).

Notes
Safari SVG output is already close to the performance of Firefox Native MathML. But it's hard to judge the 300ms for Safari's MathML since that implementation is incomplete -- it's easy to be fast if you're not doing the job. However, in Safari's defense, the page is within the range of its abilities.
(翻译: Safari 上mathjax的 SVG 输出(1000 毫秒)已经接近 Firefox 上的原生 MathML(880毫秒)。但是 Safari 对 MathML 的实现是不完整的——如果你做更少的工作,自然会就很快。但是,Safari 辩护称,就该测试页面而言,它完全在其能力范围内。)

Another comparison: a copy of the page, with SVG output and equation chunking to 100 (so that it's one go).

Nexus 7, Galaxy Nexus/ Chrome: ~18sec
Nexus 7 / Dolphin Browser: ~8.5sec
iPad (2013) / Safari: ~3sec
iPhone 4 / Safari: ~6sec
on ubuntu 13.04, i7:

Firefox 22: ~2sec
Chromium 28: ~1.6sec
Chrome 29: ~1.7sec
Windows 8 / IE 10: ~2.5sec (virtualbox + Microsoft's free testing VM)
Windows 7 / IE9: ~3sec (virtualbox + Microsoft's free testing VM)
Windows 7 / Firefox 22: ~3.8sec (virtualbox + Microsoft's free testing VM)
Windows 8.1 / IE11: ~3sec (virtualbox + release candidate)
A copy of the page with TeX converted to MathML was ~0.5-1 sec slower.

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-1-13 14:56
这些 mathjax 的讨论都 N 年前的了……现在都完全改变了吧?

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-1-28 07:02

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-1-28 20:57
回复 4# hbghlyj

嗯,我也尝试一下这个,看看效果如何。
文档里说向前引用编号会引不了,这在论坛上不打紧。

730

主题

1万

回帖

9万

积分

积分
93613
QQ

显示全部楼层

kuing 发表于 2022-1-29 14:53
Lazy Typesetting 之后,感觉打开页面显示公式时还没以前那么快,往下拉时公式的显示速度也不够快,拉得快时很明显。
草稿本就更明显了,每按一键,公式那边就闪一下,之前是不会闪的。
还是原来的感觉爽一点。
晚点就改回去。

=====
已改回去

3149

主题

8386

回帖

6万

积分

$\style{scale:11;fill:#eff}꩜$

积分
65391
QQ

显示全部楼层

 楼主| hbghlyj 发表于 2022-2-3 21:21
回复 5# kuing
除了"向前引用编号会引不了"之外还有一个问题:在前面用def或者newcomman定义的命令,如果没有加载,就变成未定义的.

手机版|悠闲数学娱乐论坛(第3版)

GMT+8, 2025-3-4 15:26

Powered by Discuz!

× 快速回复 返回顶部 返回列表