LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Direct usage of global window object #124

Closed davidkudera closed 8 years ago

davidkudera commented 8 years ago

One of the main reasons why people should use commonjs or amd is to be sure, that their object and also objects from foreign libraries does not mess up the global scope and does not use the global object directly.

It's great that this library now supports these techniques, but it violates this "rule" too a little bit.

Some examples of the "right" aproach:

Also there is this nice article: http://ifandelse.com/its-not-hard-making-your-library-support-amd-and-commonjs/

LPology commented 8 years ago

Thanks for the feedback. Would this be better?

http://pastebin.com/uxTYuT2S

Modeled after the nette/forms link.

LPology commented 8 years ago

Also, do you mind pointing to some specific instances of where you see potential issues? Any help would be great.

davidkudera commented 8 years ago

I think that would be great :+1:

The thing is that with such a code, your library would be completly isolated from the global scope.

Imagine for example tests, you don't need to work with global window, you can simply use some mocked window object only with needed properties or functions.

Or if developer install some other library which also uses the ss variable, either yours or the other library will not work properly (or at all)...

Simply put, no one can now break your library from outside and also your library can't break any other (only itself :wink:).

LPology commented 8 years ago

Forgot to close this out before. Thanks for your input.