hashmd icon indicating copy to clipboard operation
hashmd copied to clipboard

Only import the necessary functions needed from lodash

Open SkepticMystic opened this issue 3 years ago • 4 comments

Hey there :)

I was looking into slow loading times after adding bytemd. In the network tab, it shows that every lodash function is being imported, which surely isn't necessary? It might not add that much to the loading time (I'm not sure?), but it seems like an easy performance boost.

I believe the problem originates from this line: https://github.com/bytedance/bytemd/blob/178712baa4fad57b834623496341579d69b54815/scripts/postinstall.mjs#L5

SkepticMystic avatar Aug 13 '22 16:08 SkepticMystic

Another issue is that every single icon from @icon-park/svg is being imported. Is that also necessary? In total, there must be hundreds of extra dependencies being imported

SkepticMystic avatar Aug 13 '22 17:08 SkepticMystic

Which bundler are you using?

Given Vite as an example, it should bundle all dependencies into a file before starting the dev server.

pd4d10 avatar Aug 16 '22 06:08 pd4d10

I am using Vite, yeah. I don't quite understand what that means. Are you saying it's unavoidable if I use Vite?

SkepticMystic avatar Aug 16 '22 07:08 SkepticMystic

Are you saying it's unavoidable if I use Vite

Quite the contrary, I guess it should avoid this problem.

Could you please provide a minimal reproduction? So we can look into it

pd4d10 avatar Aug 16 '22 07:08 pd4d10