-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fileserver: optimize browse template to avoid SVG icon duplication #5806
fileserver: optimize browse template to avoid SVG icon duplication #5806
Conversation
glowinthedark seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
92cc040
to
2f10ef3
Compare
Good idea! This does have one downside though that for very small directories, it'll ship every SVG even if there's only one that might be used. Your approach is certainly better for huge directories, but it's a bit worse for small directories. The absolute-best option would be to only add the SVG ref if there's a relevant file included (and only include it once) but I'm not sure if we have sufficient template tooling to make that easy to do 🤔 Maybe we could loop through the directory listing once in Go code to collect a list of unique extensions (or a |
@francislavoie: indeed, I didn't consider that the way it works now it will only pull the extensions that are used, yet it all probably comes down to estimating the cost: the unminified SVG for all icons takes up 14KB, and when minified it's 8.8KB — this is cheap, although accounting is always hard. )) I didn't check how many files would need to be in a directory in order to generate a bigger file size by rendering the same icons repeatedly. |
Out of curiosity generated some stats:
All files were generated of .txt type with this bash script mkdir dir{10,20,50,100,500,1000}
touch dir10/{1..10}.txt
touch dir20/{1..20}.txt
touch dir50/{1..50}.txt
touch dir100/{1..100}.txt
touch dir500/{1..500}.txt
touch dir1000/{1..1000}.txt With up to 50 files the master version is more efficient, and the optimization will only make sense with folders with over 100 items. Do you think it is worth optimizing? I am in two minds.. I would rather revert to the current approach in |
Thanks for those stats! Very useful. Also worth checking is gzipped size (if you didn't already). I think repeated SVG will compress very well. But it's true that linked SVG will probably perform better in the browser (refs instead of copies) though that's also a micro optimization. I agree I lean towards |
2a3d395
to
cbd9595
Compare
9474c80
to
f2ab709
Compare
Description
Multiple file entries of the same type inline the entire SVG icon content which results in the same SVG icons being rendered in HTML multiple times which increases file size.
<input type="search">
instead oftext