↑ ↓ auswählen, Enter öffnen, Esc schließen

Bilder und Performance

Ladezeit entscheidet über Absprungrate und Ranking. Hier stehen Befehle, um Bilder zu verkleinern und nach WebP oder AVIF umzuwandeln, große Medien zu finden, Kompression und Cache-Header zu prüfen.

21 Einzeiler: 12 harmlos, 5 vorsicht, 4 destruktiv

Antwortzeit einer PHP-Seite mit einer statischen Datei vergleichen

$for u in https://example.com/ https://example.com/wp-includes/css/dist/block-library/style.min.css; do curl -o /dev/null -s -w "%{time_starttransfer}s TTFB $u\n" "$u"; done
harmlos

Bilder mit Abmessungen über X Pixel finden

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec identify -format '%w %h %i\n' {} + 2>/dev/null | awk -v max=2560 '$1 > max || $2 > max'
harmlos

Bilder mit GPS-Koordinaten finden

$exiftool -r -ext jpg -ext jpeg -if '$gpslatitude' -p '$directory/$filename' /var/www/vhosts/example.com/httpdocs/wp-content/uploads 2>/dev/null
harmlos

Bilder ohne loading-Attribut auf einer Seite finden

$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<img[^>]*>' | grep -vi 'loading='
harmlos

Bilder rekursiv nach AVIF umwandeln

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.avif" ] || avifenc -s 6 "$f" "$f.avif" >/dev/null; done' sh {} +
vorsicht

Bilder rekursiv nach WebP umwandeln

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec sh -c 'for f; do [ -e "$f.webp" ] || cwebp -quiet -q 80 "$f" -o "$f.webp"; done' sh {} +
vorsicht

Cache-Control aller CSS-, JS- und Bilddateien einer Seite prüfen

$curl -s https://example.com/ | grep -oE '(src|href)="[^"]+\.(css|js|woff2?|jpe?g|png|gif|webp|avif|svg)(\?[^"]*)?"' | cut -d'"' -f2 | sed -E 's#^//#https://#; s#^/#https://example.com/#' | grep '^http' | sort -u | while read -r a; do printf '%-45s %s\n' "$(curl -sI "$a" | grep -i '^cache-control:' | tr -d '\r')" "$a"; done
harmlos

CSS-, JS- und SVG-Dateien mit gzip und Brotli vorkomprimieren

$find /var/www/vhosts/example.com/httpdocs/wp-content/themes -type f \( -name '*.css' -o -name '*.js' -o -name '*.svg' \) -exec gzip -k -9 -f {} + -exec brotli -k -f {} +
vorsicht

Ersparnis durch gzip und Brotli für eine URL messen

$for e in identity gzip br; do curl -s -o /dev/null -H "Accept-Encoding: $e" -w "$e: %{size_download} Bytes\n" https://example.com/; done
harmlos

EXIF- und andere Metadaten aus Bildern entfernen

$exiftool -r -ext jpg -ext jpeg -all= -overwrite_original /var/www/vhosts/example.com/httpdocs/wp-content/uploads
destruktiv

Gesamtgröße einer Seite mit allen Assets grob ermitteln

$wget -q -p -H -nd -e robots=off -P /tmp/seitengewicht https://example.com/; du -sh /tmp/seitengewicht; ls -lhS /tmp/seitengewicht | head -15
harmlos

Große Bilder in wp-content/uploads finden

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' -o -iname '*.gif' -o -iname '*.webp' \) -size +500k -printf '%s\t%p\n' | sort -rn | head -50 | numfmt --field=1 --to=iec
harmlos

Große Bilder mit mogrify auf Maximalgröße verkleinern

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' -o -iname '*.png' \) -exec mogrify -resize '2560x2560>' {} +
destruktiv

HTTP/3-Unterstützung über den Alt-Svc-Header prüfen

$curl -sI https://example.com/ | grep -i '^alt-svc'
harmlos

JPEG-Bilder verlustfrei mit jpegoptim optimieren

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' \) -exec jpegoptim --strip-all --preserve {} +
vorsicht

JPEG-Qualität mit jpegoptim auf einen Höchstwert begrenzen

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f \( -iname '*.jpg' -o -iname '*.jpeg' \) -exec jpegoptim --strip-all --preserve --max=82 {} +
destruktiv

Nicht minifizierte CSS- und JS-Dateien finden

$find /var/www/vhosts/example.com/httpdocs/wp-content -type f \( -name '*.css' -o -name '*.js' \) ! -name '*.min.*' -size +20k -exec sh -c 'echo "$(wc -l < "$1") $1"' sh {} \; | awk -v n=200 '$1 > n' | sort -rn | head -30
harmlos

PNG-Bilder verlustbehaftet mit pngquant verkleinern

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -iname '*.png' -exec pngquant --quality=65-85 --skip-if-larger --strip --force --ext .png {} +
destruktiv

PNG-Bilder verlustfrei mit optipng optimieren

$find /var/www/vhosts/example.com/httpdocs/wp-content/uploads -type f -iname '*.png' -exec optipng -o2 -strip all -preserve {} +
vorsicht

Skripte ohne async oder defer auf einer Seite finden

$curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<script[^>]*src=[^>]*>' | grep -viE 'async|defer|type=.?module'
harmlos

Webfont-Dateien und ihre Größe finden

$find /var/www/vhosts/example.com/httpdocs/wp-content -type f \( -iname '*.woff2' -o -iname '*.woff' -o -iname '*.ttf' -o -iname '*.otf' -o -iname '*.eot' \) -printf '%s\t%p\n' | sort -rn | head -30 | numfmt --field=1 --to=iec
harmlos

Erst lesen, dann ausführen.

Die Befehle auf myline.de greifen direkt in Server, Dateien und Datenbanken ein. Ein falscher Pfad oder Platzhalter kann Daten unwiderruflich löschen oder einen Server unerreichbar machen.

  • Alle Befehle werden ohne Gewähr bereitgestellt und sind nicht auf jedem System getestet.
  • Vor dem Ausführen verstehen, was ein Befehl tut, und jeden Platzhalter prüfen.
  • Vorher ein Backup anlegen und möglichst zuerst auf einem Testsystem ausprobieren.
  • Die Ausführung erfolgt auf eigene Verantwortung. Eine Haftung für Schäden ist ausgeschlossen, soweit gesetzlich zulässig.