News for hackers. Stuff that matters.
Re:EasyDropzoneJS – open-source JavaScript library for drag&... by mkoryak on Saturday August 05, 2023 @08:31PM (#37017690)
You shouldn't pollute window with stuff if you don't have to. You created a function called `h` among with a few other things.

Otherwise good job making a thing that has been made many times before

Re:EasyDropzoneJS – open-source JavaScript library for drag&... by lioeters on Saturday August 05, 2023 @09:37PM (#37018115)
To the author, here's a common pattern you can use to avoid defining global variables unless it's needed.

  ;(function() {
    const dropzoneDefaults = { ... }
    class EasyDropzone { ... }
    const h = function() { ... }

    // Export to global
    window.EasyDropzone = EasyDropzone
  })()
Re:EasyDropzoneJS – open-source JavaScript library for drag&... by pazvanti on Sunday August 06, 2023 @02:23AM (#37019470)
Thanks. Will definitely try to improve the code. JavaScript is not my main language and I still have many tricks that I should learn.
Re:EasyDropzoneJS – open-source JavaScript library for drag&... by lioeters on Sunday August 06, 2023 @06:42AM (#37020674)
Here is some information about this pattern, it's called Immediately Invoked Function Expression. It's a way to create a function scope so that all variables are local, except for any that you want to "export" as a global.

https://developer.mozilla.org/en-US/docs/Glossary/IIFE

Re:EasyDropzoneJS – open-source JavaScript library for drag&... by pazvanti on Sunday August 06, 2023 @02:24AM (#37019473)
It has been made many times, but I could not find something that works easily out of the box. After I made it, decided to share it since others may find it useful.
Re:EasyDropzoneJS – open-source JavaScript library for drag&... by jurimasa on Sunday August 06, 2023 @11:22AM (#37022926)
Wow. So snarky. Much devel. XD