Commit Graph

6 Commits

Author SHA1 Message Date
Hikaru Y
779ca57660
Refactor CSS/image preloading; implement custom font preloading (#2356)
* Refactor CSS preloading

- Rename css.ts to preload.ts
- Rename type/function names
- Automatically remove style/link element on load/error event

* Refactor image preloading

- Reuse template element
- Change timeout value from 100ms to 200ms, as it often takes more than
  100ms to load even a single small image on a low-spec machine
- Refactor preloadAnswerImages():
  - Use 'new Image()' instead of <link rel=preload>
  - Stop calculating images that only appear on the answer side as
    cached images are resolved immediately

* Update tsconfig.json

es2020.string -> String.matchAll()
es2018.regexp -> RegExprMatchArray.groups

* Implement custom font preloading

Font files for some languages such as Chinese and Japanese can be as
large as 20MB, so we set the timeout value to 800ms for font preloading.
2023-05-10 13:26:02 +10:00
Damien Elmes
b2049209ff Re-enable formatting for .ts files
There are some style differences compared to prettier, and not all are
necessarily an improvement, but it's much faster now.
2022-11-28 09:33:04 +10:00
kelciour
3973f27ee4
Maybe preload images (#2165) 2022-11-04 10:07:51 +10:00
Henrik Giesel
0dff5ea3a3
Use trailingComma: all setting in .prettierrc (#1435) 2021-10-19 09:06:00 +10:00
hikaru-y
207e4253f1 Use <template> element instead of Range.createContextualFragment()
https://forums.ankiweb.net/t/audio-in-back-template-is-played-on-front-template-on-desktop-2-1-46/12399

Unlike when using <template> element, if a DocumentFragment is created
using Range.createContextualFragment(), <audio>/<video> elements
with `aotoplay` will play immediately even before they are inserted into
the actual document, which will cause audio or video on the answer side
to be played on the question side.
2021-08-18 00:04:02 +09:00
Henrik Giesel
ee1a1c35fb Create reviewer/images.ts 2021-07-16 16:56:56 +02:00