Does open source JavaScript work?

There is a lot of talk on the Internet right now about how important it is to minimize your JavaScript. Speed ​​is all that matters.

But does minimization work against open source openness?

One of the great features of JS (as opposed to flash and background) is that the source code is right there, accessible by other developers who come and think: "Hey, that looks good, I wonder how they are done". JS source code is available for everyone to view, and therefore developers can learn from it, adapt it and use similar JS for their own projects.

Minifying JS makes it unreadable. This prevents the external developer from reading code, and therefore cancels horizontal sharing and learning.

Obviously, there will be some who want to minimize their JS in order to pursue their intellectual property. It is always a shame when people undermine the creativity of the open source community, but this is somewhat understandable and, of course, will not stop.

But for the rest of us, developers - people who use open-source every day in our lives - JS minification gets in our way. This makes us unable to take advantage of the discovery of the Internet. This closes the possibility of creative exchange.

I'm all about some things that can be reduced - libraries, plugins, etc. (and, possibly, when servicing JS on a mobile). But for custom code that makes your individual website personal, a minimal code is not needed. This can save a few milliseconds of boot time, but keeping it open will not change that much. Most sites on the Internet probably have less than 20KB of custom JS code, and the advantage of minimizing is really minimal. Are several ms really compared to keeping JS code open, readable, and accessible to others?

For sites with a lot of JS, perhaps we could start developing an open source standard so that developers can enter a slightly different URL to serve insecure code. If the minified code is in domain.com/script.min.js, let unminified be always available on domain.com/script.js or /script.full.js. Or are there any other suggestions?

I can not find anything else on the Internet talking about this problem. Everything is on the other side - pushing mineralization. And that worries me. This makes me think that, as developers, we allowed ourselves to plunge into the undeniable ideology of speed, regardless of other factors. And, probably, because of the nature of ideology, some of you reading this will immediately want to reject it and object to it. But think a little more - is this a tiny speed advantage that is really worth the loss of open source creativity? I do not believe that this is so.

So, I think my question is, where is the debate about open source JavaScripting?

+4
source share
4 answers

I'm sure most - if not all - of the open source JavaScript libraries that offer mini versions also offer original sources for developers. This is just like open source programs that distribute compiled binaries for general use also distribute their source sources to the public.

If you link to custom scripts made on the basis of each project specifically for a specific project, these scripts are not open source by default, unless the author refers / does not contain a FOSS license notice. For this purpose, I am not obligated to provide an unlimited version of my custom code, unless I intend to distribute it freely and license it as such.

+10
source

If javascript is intended for use with open source, you can also find an uninfected version. For example jQuery:

http://docs.jquery.com/Downloading_jQuery

Both "mined" and "uncompressed" files are available for download.

If you find a javascript file that claims to be open source and does not have an uncompressed file available, an error has been made.

+1
source

Because there is no debate; I have not seen many (any?) FOSS JS libs that do not have a version without restrictions.

Even if it were, FOSS did not mean readability - even non-minified code can be completely illegible.

+1
source

One of the great things about JS (as opposed to flash and back-end) is that the source code is right there, accessible to which other developers come and think: “Hey, that looks good, I wonder how they did it "

I don't think we really want to encourage the practice of learning Javascript from the source of websites that accidentally stumbled upon them. If you want to learn Javascript, it is much better to learn from a real open source project that has been documented, tested, and written with care .

99% of the time, if I don’t open the JS source code, it’s not because of intellectual property issues. This is because it is a quick hack - not suitable for public consumption.

Most sites on the Internet probably have less than 20 KB of custom JS code and a minimization advantage that is really minimal.

Regardless of whether saving 2 kb (which still matters, by the way) or 2 MB, minimization is best practice and should be implemented by get-go developers.

+1
source

Source: https://habr.com/ru/post/1381336/


All Articles