Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doesn't JavaScript Minification hurt open source? [closed]

There's an awful lot on the web these days about how important it is to minify your JavaScript. Speed is all that matters.

But doesn't minification work against the openness of Open Source?

One of the great things about JS (as opposed to flash and the back-end) is that the source code is right there, available to be viewed by other developers who come along and think "Hey, that looks good, I wonder how they did that". The JS source code is available for everyone to see, and so developers can learn from it, adapt it, and use similar JS on their own projects.

Minifying JS makes it unreadable. It stops the external developer from being able to read the code, and so cancels out horizontal sharing and learning.

Obviously there will be some who wish to minify their JS for the express purpose of attempting to hold on to their intellectual property. It's always a shame when people undermine the creativity of the open-source community, but it's somewhat understandable, and certainly not going to stop.

But for the rest of us developers - the people who use open-source every day of our lives - JS minification gets in our way. It makes us unable to take advantage of the openness of the web. It closes down the possibility of creative sharing.

I'm all about some things being minified - libraries, plugins, etc (and maybe when serving JS to mobile). But for the custom-built code that makes your individual website individual, minifying your code is really not that necessary. It may save a few ms of download time, but keeping it open won't change that much. Most of the sites on the web probably have less than 20KB of custom JS code, and the benefit of minifying that really is minimal. Do a few ms really compare with the benefit of keeping JS code open, readable and available for others?

For sites with more JS, maybe we could start to develop an open-source-based standard, so that developers can type in a slightly different URL in order to be served the unminified code. If the minified code is at domain.com/script.min.js, let's make the unminified always available at domain.com/script.js or /script.full.js. Or are there other suggestions?

I can't really find anything else on the web talking about this issue. Everything is on the other side - pushing minification. And that alarms me. It makes me think that, as developers, we've allowed ourselves to sink into an unquestioned ideology of speed, regardless of other factors. And probably, because of the nature of ideology, some of you reading this will immediately want to dismiss it and argue against it. But think just a little bit longer - is the tiny speed benefit really worth the loss of open-source creativity? I don't believe it is.

So I guess my question is, where's the debate about open-source JavaScripting?

like image 644
thugsb Avatar asked Nov 15 '11 16:11

thugsb


People also ask

Should you minify your JS?

It is important to minify your CSS and minimise JavaScript files so they can load faster on your web pages. There are many reasons why you should minify your CSS and JavaScript: Reduce file size: The more code there is in a file, the larger it will be. Minified code is usually much smaller than the original version.

Does Minification improve performance?

Minification is the process of minimizing code and markup in your web pages and script files. It's one of the main methods used to reduce load times and bandwidth usage on websites. Minification dramatically improves site speed and accessibility, directly translating into a better user experience.

Does Minification reduce parse time?

Minification of JavaScript files reduces payload and script parse time, resulting in faster page loads.

How does JavaScript Minification work?

How Minification Works. Minification works by analyzing and rewriting the text-based parts of a website to reduce its overall file size. Minification extends to scripts, style sheets, and other components that the web browser uses to render the site. Minification is performed on the web server before a response is sent ...


2 Answers

I'm pretty sure most — if not all — open source JavaScript libraries that offer minified versions also offer the original sources for developers to work on. It's just like how open source programs that distribute compiled binaries for general use also distribute their original sources to the public.

If you're referring to custom scripts made on a per-project basis specifically for a certain project, those scripts are not open source by default unless the author specifically cites/includes a FOSS license notice. To that end, I'm not obliged to provide an unminified version of my custom code unless I intend to distribute it freely and license it as such.

like image 176
BoltClock Avatar answered Sep 18 '22 02:09

BoltClock


If the javascript is meant to be open source then you will also be able to find the un-minified version. For example, jQuery:

http://docs.jquery.com/Downloading_jQuery

There are both "minified" and "uncompressed" files for download.

If you find a javascript file which claims to be open source and does not have the uncompressed file available, then a mistake has been made.

like image 20
tybro0103 Avatar answered Sep 19 '22 02:09

tybro0103