Optimize logo file sizes to reduce webpack bundle size (#7979)
## Summary - Optimized 13 logo files, reducing total size by ~560KB - Converted hylo.svg (321KB) and nim.svg (126KB) to optimized PNGs (27KB, 13KB) - Resized oversized images to max 256×256 while preserving aspect ratios - Optimized SVGs with SVGO where beneficial - Fixed file permissions (removed execute bits from image files) - Added comprehensive README.md with optimization guidelines ## Files Changed - `lib/languages.ts`: Updated references from hylo.svg → hylo.png, nim.svg → nim.png - `public/logos/`: Optimized multiple logo files - `public/logos/README.md`: New optimization guidelines for future logo additions ## Size Reductions - hylo.svg → hylo.png: 321KB → 27KB (92% reduction) - nim.svg → nim.png: 126KB → 13KB (90% reduction) - scala.png: 79KB → 14KB (82% reduction) - haskell.png: 19KB → 6.5KB (66% reduction) - pony.svg: 53KB → 35KB (34% reduction) - odin.png: 48KB → 27KB (44% reduction) - nix.svg: 26KB → 5KB (81% reduction) - gimple.svg: 21KB → 11KB (48% reduction) - spice.png: 16KB → 9.3KB (42% reduction) - hook.png: 14KB → 9.3KB (34% reduction) - hook-dark.png: 13KB → 9.3KB (28% reduction) ## Test plan - [x] Verify all logos display correctly in the language selection UI - [x] Confirm no broken image references - [x] Check that webpack bundle size warnings are reduced - [x] Ensure visual quality is acceptable at small icon sizes 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
@@ -493,7 +493,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
|
||||
monaco: 'hylo',
|
||||
extensions: ['.hylo'],
|
||||
alias: [],
|
||||
logoFilename: 'hylo.svg',
|
||||
logoFilename: 'hylo.png',
|
||||
logoFilenameDark: null,
|
||||
formatter: null,
|
||||
previewFilter: null,
|
||||
@@ -607,7 +607,7 @@ const definitions: Record<LanguageKey, LanguageDefinition> = {
|
||||
monaco: 'nim',
|
||||
extensions: ['.nim'],
|
||||
alias: [],
|
||||
logoFilename: 'nim.svg',
|
||||
logoFilename: 'nim.png',
|
||||
logoFilenameDark: null,
|
||||
formatter: null,
|
||||
previewFilter: null,
|
||||
|
||||
44
public/logos/README.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# Logo Optimization Guidelines
|
||||
|
||||
This directory contains logos for programming languages displayed in Compiler Explorer. To maintain fast loading times and reasonable bundle sizes, logos should be optimized before adding them.
|
||||
|
||||
## Size Guidelines
|
||||
|
||||
- **Target size**: Keep individual logos under 20KB when possible
|
||||
- **Maximum dimensions**: 256×256 pixels (preserving aspect ratio)
|
||||
- **File formats**: SVG preferred for simple graphics, PNG for complex images
|
||||
|
||||
## Optimization Tools & Commands
|
||||
|
||||
### PNG Images
|
||||
```bash
|
||||
# Resize and optimize (preserves aspect ratio)
|
||||
convert input.png -resize 256x256> -quality 85 output.png
|
||||
|
||||
# Alternative with pngquant for better compression
|
||||
pngquant --quality=65-80 --output output.png input.png
|
||||
```
|
||||
|
||||
### SVG Images
|
||||
```bash
|
||||
# Optimize with SVGO (install with: npm install -g svgo)
|
||||
npx svgo input.svg --output output.svg
|
||||
|
||||
# For SVGs with embedded raster data, convert to PNG instead
|
||||
convert input.svg -resize 256x256 -quality 85 output.png
|
||||
```
|
||||
|
||||
## Common Issues
|
||||
|
||||
- **Embedded Base64 data in SVGs**: These are usually very large (300KB+). Convert to PNG instead.
|
||||
- **Oversized PNGs**: Images over 1000px wide/tall should be resized to 256×256 or smaller.
|
||||
- **16-bit PNGs**: Convert to 8-bit with `convert input.png -depth 8 output.png`
|
||||
|
||||
## Recent Optimizations
|
||||
|
||||
Examples of successful optimizations:
|
||||
- `hylo.svg` (321KB) → `hylo.png` (27KB) - 92% reduction
|
||||
- `nim.svg` (126KB) → `nim.png` (13KB) - 90% reduction
|
||||
- `scala.png` (79KB) → optimized (14KB) - 82% reduction
|
||||
|
||||
Always test that optimized logos look good at small icon sizes (16-32px) in the UI.
|
||||
0
public/logos/clean.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 8.6 KiB |
0
public/logos/cpp.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
0
public/logos/dotnet.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
0
public/logos/erlang.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.0 KiB After Width: | Height: | Size: 1.0 KiB |
0
public/logos/fsharp.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 692 B After Width: | Height: | Size: 692 B |
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 8.8 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 9.2 KiB |
BIN
public/logos/hylo.png
Normal file
|
After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 320 KiB |
0
public/logos/ispc.png
Executable file → Normal file
|
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 2.9 KiB |
BIN
public/logos/nim.png
Normal file
|
After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 47 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 8.2 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 14 KiB |
0
public/logos/solidity.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 9.2 KiB |
0
public/logos/ts.svg
Executable file → Normal file
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
@@ -54,7 +54,7 @@ const hasGit = fs.existsSync(path.resolve(__dirname, '.git'));
|
||||
// Hack alert: due to a variety of issues, sometimes we need to change
|
||||
// the name here. Mostly it's things like webpack changes that affect
|
||||
// how minification is done, even though that's supposed not to matter.
|
||||
const webpackJsHack = '.v60.';
|
||||
const webpackJsHack = '.v61.';
|
||||
const plugins: Webpack.WebpackPluginInstance[] = [
|
||||
new MonacoEditorWebpackPlugin({
|
||||
languages: [
|
||||
|
||||