asayler / COG-Web

Web Frontend for COG
GNU Affero General Public License v3.0
2 stars 3 forks source link

Fix Synchronous XMLHttpRequest Depreciation on File Upload #14

Closed asayler closed 8 years ago

asayler commented 9 years ago

jquery-2.1.1.min.js:4 - Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

hexacyanide commented 8 years ago

I was inspecting the code at js/cog_api.js#L58; is there any specific reason that the request is performed synchronously? On a cursory inspection, the code already appears to be written in such a way that it would work fine even if the request were nonblocking.

asayler commented 8 years ago

No real reason, just laziness (and lack of js expertise) on my part. Patches welcome!

asayler commented 8 years ago

Also, using async we may need some form of progress bar or other UI interaction to make sure the user doesn't try to change any settings or otherwise disrupt the submission fow while the upload is in progress. Not sure if that will be an issue or not, but may be worth considering.

hexacyanide commented 8 years ago

Since the current code already uses callbacks, I believe the functionality is already in place, but I do think it'd be worthwhile to implement a progress feature of some sort. For larger file uploads, where a user might mistake long upload times for an unresponsive web page, a progress indicator might lead to less prematurely-terminated file uploads on the API server side.