You should be able to get the frame count with the libwebp C API specified in
demux.h:
WebPData webp_data;
webp_data.bytes = ...; // Pointer to WebP file data
webp_data.size = ...; // WebP file size
WebPDemuxer* demux = WebPDemux(&webp_data);
uint32_t frame_count = WebPDemuxGetI(demux, WEBP_FF_FRAME_COUNT);
... // Use frame_count
WebPDemuxDelete(demux);
Alternatively you may use other implementations such as
node-webpmux:
const WebP = require('node-webpmux');
let img = new WebP.Image();
await img.load('img.webp');
// Use img.frameCount
Please note that third party solutions are not endorsed by WebP-discuss.