↑ ↓ select, Enter open, Esc close

Find scripts without async or defer on a page

Adjust the values, the command updates live
user@server
curl -s https://example.com/ | tr '\n' ' ' | grep -oiE '<script[^>]*src=[^>]*>' | grep -viE 'async|defer|type=.?module'

Shows every <script src> without async, defer or type="module". Such scripts stop the browser from parsing until they are loaded and executed, which delays First Contentful Paint and LCP. Matches in the <head> are especially critical.

Note: Scripts at the end of <body> hardly block, but they are listed too. Scripts that depend on jQuery cannot always be switched to defer safely.

Also searched as

  • find render-blocking resources
  • javascript without defer
  • eliminate render-blocking scripts pagespeed
  • scripts in head slow down page

Find images without a loading attribute on a page

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

Measure TTFB repeatedly with minimum, median and maximum

$for i in $(seq 10); do curl -o /dev/null -s -w '%{time_starttransfer}\n' https://example.com/; done | LC_ALL=C sort -n | awk '{a[NR]=$1; s+=$1} END {printf "Min: %.3fs Median: %.3fs Max: %.3fs Schnitt: %.3fs\n", a[1], a[int((NR+1)/2)], a[NR], s/NR}'
harmlessSEO checks

Check Cache-Control of all CSS, JS and image files on a page

$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
harmlessImages and performance

Check HTTP/3 support via the Alt-Svc header

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

Compare the response time of a PHP page with a static file

$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
harmlessImages and performance

Find unminified CSS and JS files

$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
harmlessImages and performance

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.