Username: 
Password: 
Restrict session to IP 

Country Flags

Global Rank: 200
Totalscore: 110795
Posts: 1822
Thanks: 1403
UpVotes: 984
Registered: 18y 245d




Last Seen: 14d 8h
The User is Offline
Country Flags
Google/translate0Thank You!1Good Post!1Bad Post! link
I just had a great idea: Use a spritemap for country flags, using the ISO2 codes as coordinates.

Like AL is x=0 y=12 (approx) or DE is 4|5

I just told our codex gpt about this and she completely implemented it on her own for an app within three minutes.

This saves like 242 requests for the first visit to a profile page.

A simple idea, and if i had to implement this, i would have taken like an hour.
I estimate my token cost to $0.01 for this little gem Smile

Golden Times!
- giz
The geeks shall inherit the properties and methods of object earth.
Global Rank: 200
Totalscore: 110795
Posts: 1822
Thanks: 1403
UpVotes: 984
Registered: 18y 245d




Last Seen: 14d 8h
The User is Offline
RE: Country Flags
Google/translate0Thank You!0Good Post!0Bad Post! link
Another nice idea i had a few weeks ago:

Display the Timezone Info as current time instead of offset.

Way cooler
Cool
The geeks shall inherit the properties and methods of object earth.
Global Rank: 200
Totalscore: 110795
Posts: 1822
Thanks: 1403
UpVotes: 984
Registered: 18y 245d




Last Seen: 14d 8h
The User is Offline
RE: Country Flags
Google/translate0Thank You!0Good Post!1Bad Post! link
I am looking for a volunteer that manages the spreadshirt shop.
Win wil be yours.
Make a few more colors and re-ship maybe.
- giz
The geeks shall inherit the properties and methods of object earth.
Global Rank: 30
Totalscore: 382109
Posts: 217
Thanks: 232
UpVotes: 253
Registered: 18y 229d
livinskull`s Avatar






Last Seen: 9d 14h
The User is Offline
RE: Country Flags
Google/translate1Thank You!1Good Post!0Bad Post! link
Quote from gizmore
Aug 13, 2026 - 07:51:52

This saves like 242 requests for the first visit to a profile page.


It does not, as a profile page only loads a single country flag. Worse, it loads a huge flag sprite sheet when only a few bytes flag is required ;P

Only benefit would be on pages rendering a load of different flags at once, but even then, if caching headers are set properly, single files are probably better. Modern browsers load that via one connection in HTTP/2 anyway (or keep-alive on 1.1). And once it's loaded it can be stuck into cache, basically forever. You cannot properly cache a sprite sheet, clientside, as any change to any country flag (or, a new one, or removing one) would have to invalidate it.


(This reply was AI and brainrot free)
Last edited by livinskull - Aug 15, 2026 - 09:23:50
Global Rank: 200
Totalscore: 110795
Posts: 1822
Thanks: 1403
UpVotes: 984
Registered: 18y 245d




Last Seen: 14d 8h
The User is Offline
RE: Country Flags
Google/translate0Thank You!0Good Post!1Bad Post! link
On my phpgdo7 framework I did not want completion and was too lazy for lazy loading. the spritemap is tiny... way better.

I am not talking about gwf3
The geeks shall inherit the properties and methods of object earth.
Global Rank: 1012
Totalscore: 27306
Posts: 30
Thanks: 29
UpVotes: 37
Registered: 3y 30d
Last Seen: 28d 18h
The User is Offline
RE: Country Flags
Google/translate1Thank You!1Good Post!0Bad Post! link
Quote from livinskull
Aug 15, 2026 - 09:22:40

You cannot properly cache a sprite sheet, clientside, as any change to any country flag (or, a new one, or removing one) would have to invalidate it.


But country flags don't need to be changed/added/removed often nowadays as far as I know.
So it would probably still be worth it because cache invalidations would be few and far between.

A further refinement would be to split country flags into N groups in alphabetical order (in English) and create a sprite for each group.
Instead of one big sprite, we now have N smaller sprites.
Then, when a country flag changes/is removed/is added, most of the times only the cache for 1 sprite corresponding to that country's group would get invalidated, or at most 2 in case that country changes its name (the sprite corresponding to the group it leaves and the one corresponding to the group it joins).
Country groups must be allowed to grow/shrink freely for this to be possible.
This means group size differences would accumulate over time, meaning some groups could get big enough that their probability of invalidation could become significantly higher than the others due to increased membership alone.
Also, there is of course the matter of tuning the N parameter.
However, again, countries don't change all that often, I don't think it's a problem if it becomes necessary to regenerate all the groups in 100+ years Smile.

By taking into account more data about actual countries (stability, geopolitical connection, ...), sprite groups can be created in smarter ways so as to optimize for different aspects of cache performance.
OK, enough rambling now Smile
Global Rank: 6
Totalscore: 607410
Posts: 374
Thanks: 398
UpVotes: 408
Registered: 17y 8h







Last Seen: 18s
The User is Online
RE: Country Flags
Google/translate1Thank You!1Good Post!0Bad Post! link
Have to admit, I am more on livinskull's side here (Woot, yeah, I know!!):

Don't feel that is a problem right now, and the impact will be rather small (now, on new WC hardware/software).
Global Rank: 6
Totalscore: 607410
Posts: 374
Thanks: 398
UpVotes: 408
Registered: 17y 8h







Last Seen: 18s
The User is Online
RE: Country Flags
Google/translate1Thank You!1Good Post!0Bad Post! link
EDIT: wrong Thread
Last edited by tehron - Sep 09, 2026 - 11:57:54
Global Rank: 510
Totalscore: 51999
Posts: 39
Thanks: 31
UpVotes: 54
Registered: 1y 329d
Last Seen: 1d 8h
The User is Offline
RE: Country Flags
Google/translate1Thank You!2Good Post!0Bad Post! link
Sprites are from another era, I think there should be better solutions now, like full CSS flags =)
Global Rank: 200
Totalscore: 110795
Posts: 1822
Thanks: 1403
UpVotes: 984
Registered: 18y 245d




Last Seen: 14d 8h
The User is Offline
RE: Country Flags
Google/translate0Thank You!0Good Post!0Bad Post! link
Because HTML does not allow markup in <option> the UTF8 Flags are a nice solution as well... but that does not solve the markup problem for other <select> 'D'oh
The geeks shall inherit the properties and methods of object earth.
quangntenemy, TheHiveMind, Z, balicocat, Ge0, arraez, jcquinterov, hophuocthinh, alfamen2, burhanudinn123, Ben_Dover, stephanduran89, braddie0, fpombal, csuquvq, Psycho01010 have subscribed to this thread and receive emails on new posts.
1 people are watching the thread at the moment.
This thread has been viewed 163 times.