Try to be more defensive and run only if in proper page (otherwise it breaks some UI jQuery functions).
Attach a file by drag & drop or click to upload