async function byteLengthFromUrl(url, requestInit, customFetch) {
  const fetch = customFetch ?? globalThis.fetch
  return await fetch(url, { ...requestInit, method: 'HEAD' })
    .then(res => {
      if (!res.ok) throw new Error(`fetch head failed ${res.status}`)
      const length = res.headers.get('Content-Length')
      if (!length) throw new Error('missing content length')
      return parseInt(length)
    })
}
Get the byte length of a URL using a HEAD request.
If requestInit is provided, it will be passed to fetch.

@param {string} url
@param {RequestInit} [requestInit] fetch options
@param {typeof globalThis.fetch} [customFetch] fetch function to use
@returns {Promise<number>}