Flagmeister.github.io
300+ SVG flags in one 27KB single Custom-Element/WebComponent
Install / Use
/learn @flagmeister/Flagmeister.github.ioREADME
300+ SVG Flags in one Custom Element/Web Component
https://flagmeister.github.io
<html>
<head>
<script src='elements.flagmeister.min.js'></script>
</head>
<body>
<svg-flag is="nl"><!--Netherlands--></svg-flag>
<svg-flag is="zw"><!--Zwaziland--></svg-flag>
<svg-flag is="ke"><!--Kenia--></svg-flag>
<svg-flag is="kr"><!--Soutrh Korea--></svg-flag>
<svg-flag is="es"><!--Spain--></svg-flag>
<svg-flag is="aq"><!--Antarctic--></svg-flag>
<svg-flag is="nz"><!--New Zealand--></svg-flag>
<svg-flag is="jollyroger"></svg-flag>
</body>
</html>

Errors and missing flags
There is no single truth on SVG flags. All flag sites out in the wild have errors. The most popular one flag-icons has many incorrect colors. Some are missing details in flags.
-
I first built a tool to analyse all SVG flags out there: index.html#FlagMeisterAnalyzeFlags
-
copied all SVG flags into one file
-
corrected all SVG to Viewbox 640x480
-
removed bloated SVG
-
rewrote all repeating SVG to JavaScript functions generating SVG
-
rewrote all SVG JavaScript functions to parse Strings (better for minification and performance)
-
wrote a parser to convert Strings to SVG (when you use 1 flag only 1 SVG flag is generated)
The final result is a single 26KB (GZip) Custom Element/Web Component file
a (Lipis) SVG flag:
<svg xmlns="http://www.w3.org/2000/svg" id="flag-icons-bh" viewBox="0 0 640 480"> <defs> <clipPath id="a"> <path fill-opacity=".7" d="M0 0h640v480H0z"/> </clipPath> </defs> <g fill-rule="evenodd" stroke-width="1pt" clip-path="url(#a)"> <path fill="#e10011" d="M-32.5 0h720v480h-720z"/> <path fill="#fff" d="M114.3 479.8l-146.8.2V0h146l94.3 30.4-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5 93.5 30.5-93.5 29.5"/> </g> </svg>
Becomes FlagMeistered:
bgcolor:#e10011;path:#fff,m114 480l-146 1V0h180l94 48-99 48 99 48-99 48 99 48-99 48 99 48-99 48 99 48-99 48 99
https://flagmeister.github.io
https://flagmeister.github.io/documentation.html
Resources Used
Flags
-
Flags of the World - https://flags.dsgn.it/ - https://github.com/cedmax/flags
-
flag-icons - alas almost all colors are wrong - https://flagicons.lipis.dev/
-
Kent - https://github.com/kent1D/svg-flags
-
Nillson - https://hjnilsson.github.io/country-flags/
-
FlagKit - https://github.com/madebybowtie/FlagKit
-
React Flags - Used:143 - 1.3 MB GZipped bundle - https://github.com/smucode/react-world-flags
-
React SVG flags - Used:131 - https://github.com/wiredmax/react-flags/tree/master/vendor/flags/flags-iso/flat/svg
-
Pure CSS flags - https://codepen.io/hagenburger/pen/wnkDo
-
Emoji flags
- https://ellekasai.github.io/twemoji-awesome/
- US flag: https://twemoji.maxcdn.com/2/svg/1f1fa-1f1f8.svg
- JSON https://github.com/amio/emoji.json
-
WHy not to use flags for languages - http://jkorpela.fi/flags.html
Countries
- World Countries in JSON format - https://stefangabos.github.io/world_countries/
SVG
- Edit SVG paths - https://aydos.com/svgedit/
- https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
- https://jakearchibald.github.io/svgomg/
- Scaling SVG https://css-tricks.com/scale-svg/
- Edit SVG paths - https://css-tricks.com/tools-visualize-edit-svg-paths-kinda/
SVG Filters, Masks, Clip
-
SVG shapes - http://www.kelvinlawrence.net/svg/index.html
-
https://tympanus.net/codrops/2019/01/15/svg-filters-101/
-
http://www.svgbasics.com/filters2.html
-
Square lighting : https://jsfiddle.net/p015w43j/
-
https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Filter_effects
-
https://vanseodesign.com/web-design/svg-clipping-path-examples-1/
-
!! https://css-tricks.com/animate-blob-text-with-svg-text-clipping/
-
https://1stwebdesigner.com/svg-filter-resources-and-demos/
-
https://tympanus.net/codrops/2019/02/12/svg-filter-effects-conforming-text-to-surface-texture-with-fedisplacementmap/
CSS clip path
-
https://css-tricks.com/almanac/properties/c/clip/
-
https://css-playground.com/view/65/clipping-paths-with-clip-path
-
preserveAspectRatio: https://jsfiddle.net/api/mdn/ - https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/preserveAspectRatio
-
feDiffuseLightning: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/feDiffuseLighting
Color
- https://www.schemecolor.com/?s=flag+colors
- https://www.schemecolor.com/color/country-flag
- Extrac colors from image - https://labs.tineye.com/color/
Language selectors
Ali Baba - 67 KB
https://s.alicdn.com/@g/sc/header-footer/0.0.14/sc-header-footer/$node_modules/@alife/alpha-icon/src/img/sprites/69221370.png
Apple individual images 176 KB
https://www.apple.com/choose-country-region/
Code Fragments
sed -i -ne '/<!-- BEGIN -->/ {p; r FILE1.EXT' -e ':a; n; /<!-- END -->/ {p; b}; ba}; p' OUTPUT.EXT
Lipis SVG format error (when replacing double quotes with single quote)
https://github.com/lipis/flag-icons/search?q=Linux
.replace("-inkscape-font-specification:'Linux Biolinum Bold';", '')
Waving flags
- https://www.behance.net/gallery/67823157/Animated-SVG-Polychromatic-Flag
- https://krikienoid.github.io/flagwaver/
