How can I add custom functionality in files app uploading process?

I want to prevent uploading of file if the file size is greater than some certain size on front-end(Javascript).
What is the best way to achieve this?