Here are two simple Async/Await JavaScript scripts that will detect and indicate browser support for the AVIF and WEBP image formats. The method used here is to attempt to create an image object in the test format from a base64 encoded representation of the image. Here below is the content of the two scripts.
Bob Wright
@bobnoxious
Bob has been designing hardware and coding software for decades. He likes to draw and write. He’s a web cadet wannabe.