Client side image resizing before upload?

Basically I want to allow my users to upload image files. However, any image size that are over 500kb will be compressed to 500kb.
I’ve read this thread in community:
Client side image resizing before upload? Alternative to using TinyPNG after upload - #2 by luka

and one member suggested using :compressorjs CDN by jsDelivr - A CDN for npm and GitHub

I opened the link but I have no idea how to “install” the script in weweb.