serviceworker downloads unnecessary fonts

nothingpa year ago

The traccar-web's serviceworker downloads unnecessarily robo-latin 100~900 woff files on first load, putting load on the server and clients. Since Traccar seems to work fine with only robo-latin-400 and 500, the behavior seems unnecessary. Is this intended?

Anton Tananaeva year ago

I think it's probably just the default setup for MUI.

nothingpa year ago

Well, I found this document : https://v3.mui.com/style/typography/#migration-to-typography-v2

Be careful when using this approach. Make sure your bundler doesn't eager load all the font variations (100/300/400/500/700/900, italic/regular, SVG/woff). Inlining all the font files can significantly increase the size of your bundle. Material-UI default typography configuration only relies on 300, 400 and 500 font weights.

However, typeface-roboto is now deprecated and the latest MUI documentation now suggests a different way : https://mui.com/material-ui/react-typography/

npm install @fontsource/roboto
import '@fontsource/roboto/400.css';
import '@fontsource/roboto/500.css';

How about changing to @fontsource/roboto?

Anton Tananaeva year ago

Feel free to send a pull request.