Jeff-Lewis / minify

Automatically exported from code.google.com/p/minify
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Allow non-minification of copyright/licenses #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Currently only the CSS minifier has a mechanism for leaving copyright
comments untouched. I'd prefer to remove this option from the CSS min and
create an easy way to leave arbitrary content (usually comments) unmodified.

Option 1: Give unrecognized file extensions an empty minifier by default.
The user would then move license/copyright comments to .txt files and add
them to the file lists. I like this because it actually simplifies/removes
 Minify code while making the task straightforward for the user.

Option 2: Have Minify_Javascript / Minify_Html sniff & strip out license
comments and add them back after using minification. Creates tons of
options and worries about how to determine which comments to keep, etc.

This also raises the issue: are licenses even necessary if the source files
(w/ license) are on the server (but not linked)? Would it be
better/acceptable to merge all client code licenses into a file and point
to it in a comment?

Original issue reported on code.google.com by mrclay....@gmail.com on 2 May 2008 at 5:13

GoogleCodeExporter commented 9 years ago
Of option 1 and 2, I would prefer option 1. Option 2 feels too likely to break.

Could the license text be added in the PHP code instead of external .txt files? 
This
would seem cleaner to me, each license is just a few lines long, and could just 
be
another option field in the file settings array?

I would advocate keeping the copyright statement together with the original 
work, for
2 reasons:
1) If the user saves the webpage and moves it, then any non-linked resources 
would be
lost.
2) Several licenses require that the copyright notice must be left intact, as 
one
example the modern BSD license says "Redistributions of source code must retain 
the
above copyright notice, this list of conditions and the following disclaimer."

Original comment by jm.spam...@gmail.com on 2 May 2008 at 6:53

GoogleCodeExporter commented 9 years ago
Outputting content before calling Minify::serve() will generally not work since
serve() sends headers and encodes content (so you'd have mixed encoding 
garbage).

If you *really* want to keep the comments in the PHP code, you can use a
Minify_Source and directly give it the content:

new Minify_Source(array(
  'id' => 'jsComments' // arbitrary, but required
  ,'content' => '/* put comments here */'
  ,'minifier' => ''
  ,'lastModified' => filemtime(__FILE__) // allows caching
))

Option 3: An option to prepend a multi-line comment that lists the files 
compressed:

/* This file contains compressed versions of these source files:
http://example.com/js/jquery.js 
http://example.com/js/dojo.js
http://example.com/js/user.js 
Please see the above files for copyright/license information. */

I'm still not crazy about it. I think this should be manually done via Option 2,
rather than a bunch more Minify code.

Original comment by mrclay....@gmail.com on 2 May 2008 at 8:17

GoogleCodeExporter commented 9 years ago
Option 3 looks good to me. :-)

Original comment by jm.spam...@gmail.com on 2 May 2008 at 10:01

GoogleCodeExporter commented 9 years ago
Taking cue from the YUI Compressor, I've added a "preserveComments" option 
(default
true) to Minify_Javascript in r79. This preserves multi-line comments that 
begin with
"/*!".

This requires minimal user modification to the sources, and is a pretty simple 
system
with predictable output. 

TODO: revise Minify_CSS to have the same option instead of sniffing for 
"copyright".

Original comment by mrclay....@gmail.com on 7 May 2008 at 8:21

GoogleCodeExporter commented 9 years ago
Minify_Javascript now has the "preserveComments" option, and, by default, 
preserves
multi-line comments that begin with "/*!".

Original comment by mrclay....@gmail.com on 14 May 2008 at 4:18