473,397 Members | 2,084 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

When to minify?

How much javascript would you have when you decide that minifying is
called for?
Nov 14 '08 #1
50 3821
Martin Rinehart schreef:
How much javascript would you have when you decide that minifying is
called for?
Me? When it starts resembling JQuery or prototypejs.

Seriously, how can anybody answer such a general question?

Personally, I roll all my JavaScript myself (that way I understand what
I am doing) and never found myself in a situation where I needed to
minimize the code.

Are you having any specific problems with your current JavaScript?
If so, what kind of problems? Maintainance? Performance? Crossbrowser
compatibility?
Please elaborate a little.

Regards,
Erwin Moller
--
"There are two ways of constructing a software design: One way is to
make it so simple that there are obviously no deficiencies, and the
other way is to make it so complicated that there are no obvious
deficiencies. The first method is far more difficult."
-- C.A.R. Hoare
Nov 14 '08 #2
On Nov 14, 5:32*pm, Martin Rinehart <MartinRineh...@gmail.comwrote:
How much javascript would you have when you decide that minifying is
called for?
I always try to serve them minified, BUT, do not forget to keep the
non-minified sources in a safe place: usually a "sources" folder (a
"deploy" folder holds the minified versions).

..CSS and .html files can be "minified" too...

A 1000 lines .js with soft-tabs has several kilobytes of %20's...

Also, whenever/if the UA supports it (Accept-Encoding: gzip) serve it
gzipped as well.

--
Jorge.
Nov 14 '08 #3
Martin Rinehart wrote:
How much javascript would you have when you decide that minifying is
called for?
There isn't enough "javascript" in the world to make minifying worthwhile.
Literally.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 14 '08 #4
Jorge wrote:
On Nov 14, 5:32 pm, Martin Rinehart <MartinRineh...@gmail.comwrote:
>How much javascript would you have when you decide that minifying is
called for?

I always try to serve them minified, BUT, do not forget to keep the
non-minified sources in a safe place: usually a "sources" folder (a
"deploy" folder holds the minified versions).
Since no human beings (possible savants aside) can decipher minified code in
a reasonable amount of time so as to compare if the code they use is
equivalent to the code that is in the `deploy' "folder", what should it be
good for? That's the core problem with minifying: you test code but you use
completely different code; the tests, as thorough as they may have been, are
ultimately futile. Especially as most people don't even know how the
minifier works that they are using.

My recommendation: When serving, strip the documentation comments if you
must (and provide a version that includes them also), but do not minify.
.CSS and .html files can be "minified" too...
To what end? Better support RFC 1149?
A 1000 lines .js with soft-tabs has several kilobytes of %20's...
So what? Assuming "several" means 2 (KiB), that's about 0.293 seconds
download time on a 56k modem in the best case (56 kBit/s), about 0.341
seconds in the worst case that I have seen yet (48 kBit/s). Literally
in the blink of an eye already, and broadband Internet connections,
which are more than 26 times faster than that, tend to be more common nowadays.
Also, whenever/if the UA supports it (Accept-Encoding: gzip) serve it
gzipped as well.
That's the ticket instead.
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 14 '08 #5
Martin Rinehart meinte:
How much javascript would you have when you decide that minifying is
called for?
Never? I use JSMin to strip comments and trailing spaces occasionally.
Serving one larger file instead of several small ones, and delivering it
gzipped will yield *much* better results, than all this minifiying fuss.

Gregor
Nov 14 '08 #6
Gregor Kofler <us****@gregorkofler.atwrites:
Martin Rinehart meinte:
>How much javascript would you have when you decide that minifying is
called for?

Never? I use JSMin to strip comments and trailing spaces
occasionally. Serving one larger file instead of several small ones,
and delivering it gzipped will yield *much* better results, than all
this minifiying fuss.
This. And also: nothing will reduce the size of a js file better than
gzip. See content-encoding.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
Nov 14 '08 #7
On Nov 14, 10:18 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
Since no human beings (possible savants aside) can decipher minified code in
a reasonable amount of time so as to compare if the code they use is
equivalent to the code that is in the `deploy' "folder", what should it be
good for? That's the core problem with minifying: you test code but you use
completely different code; the tests, as thorough as they may have been, are
ultimately futile. Especially as most people don't even know how the
minifier works that they are using.
I have had a problem of this kind just once, when using the
"agressive" setting (which I have never used again). But not with the
"conservative" setting. The "minimal" setting seems to just strip out
comments, empty lines and trailing spaces, if that makes you feel
better.

JSMin is the "final touch" that every (big) .js file deserves, IMO.
A 1000 lines .js with soft-tabs has several kilobytes of %20's...

So what? Assuming "several" means 2 (KiB)
2 spaces per tab stop per line account for much more than that.
that's about 0.293 seconds
download time on a 56k modem in the best case (56 kBit/s), about 0.341
seconds in the worst case that I have seen yet (48 kBit/s).
....and there are millions of mobile users out there.
Literally
in the blink of an eye already, and broadband Internet connections,
which are more than 26 times faster than that, tend to be more common nowadays.
What's in your opinion the number of kiloBytes of junk that is ok to
send again and again and again ?

--
Jorge.
Nov 15 '08 #8
On Nov 15, 12:02*am, Joost Diepenmaat <jo...@zeekat.nlwrote:
>
This. And also: nothing will reduce the size of a js file better than
gzip.
Yes: minify + gzip.

--
Jorge.
Nov 15 '08 #9
rf

"Martin Rinehart" <Ma************@gmail.comwrote in message
news:10**********************************@b38g2000 prf.googlegroups.com...
How much javascript would you have when you decide that minifying is
called for?
What everybody else said plus:
Why minimize a Javascript file to save the odd K or two then the same page
probably has a dozen images that could be better compressed (at almost zero
loss of quality) saving hundreds of K.
Nov 15 '08 #10
rf wrote:
Why minimize a Javascript file to save the odd K or two then the same page
probably has a dozen images that could be better compressed (at almost zero
loss of quality) saving hundreds of K?
Because most browsers block the loading of additional assets until the
JavaScript file has been completely loaded, compiled, and executing. The largest
component is the loading time, and minification and gzipping are very effective
optimizations.

I highly recommend that you get Steve Sourders's book on performance.
Nov 15 '08 #11
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
>>A 1000 lines .js with soft-tabs has several kilobytes of %20's...
So what? Assuming "several" means 2 (KiB)

2 spaces per tab stop per line account for much more than that.
Even if its twice that amount it is still negligible as compared to the rest
of the file.
>that's about 0.293 seconds download time on a 56k modem in the best
case (56 kBit/s), about 0.341 seconds in the worst case that I have
seen yet (48 kBit/s).

...and there are millions of mobile users out there.
You don't serve large script files to mobile devices.

Anyhow, for 2 KiB that is

13.0 kbit/s on GSM, ca. 1.260 s
14.4 kbit/s on CSD, ca. 1.138 s
115.2 kbit/s on HSCSD, ca. 0.142 s
171.2 kbit/s on GPRS, ca. 0.096 s
384.0 kbit/s on EDGE, ca. 0.043 s
384.0 kbit/s to 7.2 Mbit/s on UMTS, ca. 0.043 down to 0.002 s

And, as others have already noted, if you are worried about the script size
you really should be worried about the document and image file size first.
>Literally in the blink of an eye already, and broadband Internet
connections, which are more than 26 times faster than that, tend to be
more common nowadays.

What's in your opinion the number of kiloBytes of junk that is ok to send
again and again and again ?
Wrong question. Whitespace is _not_ junk.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 15 '08 #12
On Nov 15, 7:57*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
You don't serve large script files to mobile devices.
You don't know what you're talking about: The last iPhone webApp that
I have written (not counting iui.js): 2256 lines of JavaScript, 64592
characters -43286 characters minified (conservative setting) ->
11561 bytes gzipped.

Minification alone shrinked it by 20k+.
Anyhow, for 2 KiB that is

13.0 kbit/s on GSM, (...) etc etc
Mobile users don't get that speeds, those are (in theory) maximum
speeds, nothing to do with what you really get.

--
Jorge.
Nov 15 '08 #13
On Nov 15, 7:57*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
And, as others have already noted, if you are worried about the script size
you really should be worried about the document and image file size first..
Yeah, but not in this thread. This one is about minifying JS.

--
Jorge.
Nov 15 '08 #14
On Nov 15, 7:57*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
What's in your opinion the number of kiloBytes of junk that is ok to send
again and again and again ?

Wrong question. *Whitespace is _not_ junk.
Huh ?

--
Jorge.
Nov 15 '08 #15
Douglas Crockford wrote:
rf wrote:
I highly recommend that you get Steve Sourders's book on performance.
It's probably worthy of adding to the FAQ.

--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Nov 16 '08 #16
Jorge wrote:
On Nov 15, 7:57 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>You don't serve large script files to mobile devices.

You don't know what you're talking about: The last iPhone webApp that
I have written (not counting iui.js): 2256 lines of JavaScript, 64592
characters -43286 characters minified (conservative setting) ->
11561 bytes gzipped.

Minification alone shrinked it by 20k+.
>Anyhow, for 2 KiB that is

13.0 kbit/s on GSM, (...) etc etc

Mobile users don't get that speeds, those are (in theory) maximum
speeds, nothing to do with what you really get.
Building into one file reduces the number of HTTP requests and adds one
file into the cache (not 20 or so, which can easily happen when applying
good old SRP).

If the file is minified, it will take less room in the cache. Cache
limits are finite. In mobile devices (like iPhone), cache is generally
not as large as a desktop browser.

Garrett
--
comp.lang.javascript FAQ <URL: http://jibbering.com/faq/ >
Nov 16 '08 #17
Jorge wrote:
Thomas 'PointedEars' Lahn wrote:
>You don't serve large script files to mobile devices.

You don't know what you're talking about: The last iPhone webApp that
I have written (not counting iui.js): 2256 lines of JavaScript, 64592
characters -43286 characters minified (conservative setting) ->
11561 bytes gzipped.
I happen to own an iPhone 3G. Its support includes EDGE and UMTS. What was
your problem again?
Minification alone shrinked it by 20k+.
On EDGE (I'm not even talking about UMTS) that makes about 0.860+ s less --
blink of an eye.

That said, you don't even see the contradiction: cutting off 20k+ due to
minimization from what, about 100k+ of code? And you are actually caring
about mobile users? That's ridiculous.
>Anyhow, for 2 KiB that is

13.0 kbit/s on GSM, (...) etc etc

Mobile users don't get that speeds, those are (in theory) maximum
speeds, nothing to do with what you really get.
13.0 kbit/s *is about* the transfer rate of (original) GSM (which is not
very common anymore), channel splitting, syncing, bit error correction, and
time slots already considered. You may be right about the other transfer
rates, however even then the time difference would be negligible.

And you still miss the point.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 16 '08 #18
On Nov 16, 6:46 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
That said, you don't even see the contradiction: cutting off 20k+ due to
minimization from what, about 100k+ of code? And you are actually caring
about mobile users? That's ridiculous.
That's ridiculous:

"Cutting 30k by gzipping is allright, but cutting 20k+ by minifying
isn't."

duh!

--
Jorge.

Nov 16 '08 #19
On Nov 16, 6:46*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
That said, you don't even see the contradiction: cutting off 20k+ due to
minimization from what, about 100k+ of code? *And you are actually caring
about mobile users? *That's ridiculous.
This is ridiculous:

"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."

duh!

--
Jorge.

"Silly things such as logic, common sense, rational
thoughts or good manners are not allowed in this
forum."
Nov 16 '08 #20
As a regular user with a high-speed internet connection I don't care
about minification.

As a peek-under-the-hood user, I don't like minification.

As a frugal owner of a website hosted by a pay-by-usage service
(http://www.nearlyfreespeech.net/) I use gzip to keep my costs down &
am aware of minification -- if my site usage goes up, it is an option
that I will use to reduce costs.
Nov 17 '08 #21
Jorge wrote:
>
This is ridiculous:

"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."
And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.

Frankly, as a user who on occasion has to debug scripts on other
people's pages (typically using Firebug) and fix them (generally with
Greasemonkey-injected scripts of my own), I think "minifying" is
damned obnoxious.

I've never felt the need to read web pages, much less attempt to use
ones with grandiose scripts, on a mobile device. If I did, I'd accept
the limitations of the tools I chose to use. I don't expect my toolbox
saw to cut as fast as my power compound mitre saw.

But if you want to cater to the technophiles, that's your business.

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
Nov 17 '08 #22
On Nov 17, 9:32*pm, Michael Wojcik <mwoj...@newsguy.comwrote:
Jorge wrote:
This is ridiculous:
"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."

And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.
Yes, Wojcik, that's a good question, because most UAs "Accept-
encoding: gzip" nowadays: these are the numbers:

..js: 64592 chars.
..js: 43286 chars. (minified).
..js.gz: 14229 bytes. (gzipped).
..js.gz: 11561 bytes. (minified + gzipped).

43286/11561 = 3.74
64592/14229 = 4.54

As you guessed, the several Ks of whiteSpace allow gzip() to get a
better compression ratio.

OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.

--
Jorge.
Nov 18 '08 #23
On Nov 17, 9:32*pm, Michael Wojcik <mwoj...@newsguy.comwrote:
>
I've never felt the need to read web pages, much less attempt to use
ones with grandiose scripts, on a mobile device.
Yeah, but I'm talking about a webApp, not a page with some scripts.
You can't avoid big scripts with webApps, isn't it ?

--
Jorge.
Nov 18 '08 #24
Jorge meinte:
OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.
Indeed. Since my currently running FF occupies 280MB, I suppose the 20kB
(0.007% of 280MB) are negligible. As you said: YMMV.

Gregor
Nov 18 '08 #25
On Nov 18, 10:07*am, Gregor Kofler <use...@gregorkofler.atwrote:
Jorge meinte:
OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.

Indeed. Since my currently running FF occupies 280MB, I suppose the 20kB
(0.007% of 280MB) are negligible. As you said: YMMV.
Yeah, no need to gzip() either.

--
Jorge.
Nov 18 '08 #26
Jorge meinte:
On Nov 18, 10:07 am, Gregor Kofler <use...@gregorkofler.atwrote:
>Jorge meinte:
>>OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.
Indeed. Since my currently running FF occupies 280MB, I suppose the 20kB
(0.007% of 280MB) are negligible. As you said: YMMV.

Yeah, no need to gzip() either.
Nope - since we are talking about *transferring* either 60kB or 14kB.
Once on the client it won't make a difference.

Gregor
Nov 18 '08 #27
On Nov 18, 4:00*pm, Gregor Kofler <use...@gregorkofler.atwrote:
Jorge meinte:
On Nov 18, 10:07 am, Gregor Kofler <use...@gregorkofler.atwrote:
Jorge meinte:
>OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.
Indeed. Since my currently running FF occupies 280MB, I suppose the 20kB
(0.007% of 280MB) are negligible. As you said: YMMV.
Yeah, no need to gzip() either.

Nope - since we are talking about *transferring* either 60kB or 14kB.
Once on the client it won't make a difference.

Gregor
I give up.

--
Jorge.
Nov 18 '08 #28
Jorge meinte:
I give up.
Victory, at last! The heinous empire of minifiers defeated.
Nov 18 '08 #29
On Nov 14, 11:32*am, Martin Rinehart <MartinRineh...@gmail.comwrote:
How much javascript would you have when you decide that minifying is
called for?
Why would it matter how much?

The answer to "when to minify" is: right before you start testing the
script. As mentioned, if your server supports HTTP compression, then
the "minification" is mostly a waste (might help with the odd agent
that declines GZIP.)
Nov 19 '08 #30
David Mark wrote:
The answer to "when to minify" is: right before you start testing the
script. [...]
Right. And when the test fails, you go fix the bug ... wait a minute,
*you can't*.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 19 '08 #31
On Nov 19, 4:46*am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
The answer to "when to minify" is: right before you start testing the
script. [...]

Right. *And when the test fails, you go fix the bug ... wait a minute,
*you can't*.
And why on earth not?
Nov 19 '08 #32
Jorge wrote:
On Nov 17, 9:32 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
>I've never felt the need to read web pages, much less attempt to use
ones with grandiose scripts, on a mobile device.

Yeah, but I'm talking about a webApp, not a page with some scripts.
You can't avoid big scripts with webApps, isn't it ?
It depends on the application. I've written applications with web
front-ends that use little or no client-side scripting. But I
recognize that's not common these days.

I avoid using web applications from mobile devices just as much as I
avoid reading web pages from them. But, again, I recognize that some
people like that sort of thing, or have other reasons to do so.

My point was that different users have different preferences, so I
wouldn't advocate minimization to optimize for mobile users, unless I
believed there was a good reason to optimize for mobile users. The
mere existence of mobile users does not constitute such a reason, as
far as I'm concerned.

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
Nov 19 '08 #33
Jorge wrote:
On Nov 17, 9:32 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
>Jorge wrote:
>>This is ridiculous:
"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."
And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.

Yes, Wojcik, that's a good question, because most UAs "Accept-
encoding: gzip" nowadays: these are the numbers:

.js: 64592 chars.
.js: 43286 chars. (minified).
.js.gz: 14229 bytes. (gzipped).
.js.gz: 11561 bytes. (minified + gzipped).
Thanks. That's a useful data point.
OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.
Depends on what tradeoff developers want to make, of course, which in
turn probably ought to depend on what targets they're optimizing for.

If you're optimizing for devices with constrained resources (such as
mobile phones), then that 20KB of cache space might justify
minimization. If you're optimizing for really slow links, the 3KB of
additional data transfer might justify it.

If you're optimizing for users with lots of resources who might want
to read the source, you don't want to minimize. If you're concerned
about the possibility (however remote) of transformation effects, you
don't want to minimize.

Clearly, having relevant empirical data (as you now have for this
particular case) helps in determining what tradeoff to make.

--
Michael Wojcik
Micro Focus
Rhetoric & Writing, Michigan State University
Nov 19 '08 #34
Michael Wojcik wrote:
Jorge wrote:
>On Nov 17, 9:32 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
>>Jorge wrote:
This is ridiculous:
"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."
And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.
Yes, Wojcik, that's a good question, because most UAs "Accept-
encoding: gzip" nowadays: these are the numbers:

.js: 64592 chars.
.js: 43286 chars. (minified).
.js.gz: 14229 bytes. (gzipped).
.js.gz: 11561 bytes. (minified + gzipped).

Thanks. That's a useful data point.

[...]
Clearly, having relevant empirical data (as you now have for this
particular case) helps in determining what tradeoff to make.
Yes, but only for that particular file and not as a general recommendation,
though. For the figures will be different with different code!

In particular, it depends very much on how many unnecessary repetitions
there are in the code already; many people (and it seems especially those
that use minifiers) don't know how to write scripts properly and e.g. repeat
property accesses over and over again. That accounts for repetitions of
characters (byte sequences) as relevant for the Deflate (and any other)
compression algorithm, and is likely to account for whitespace that
minifying would replace.
PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Nov 19 '08 #35
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>The answer to "when to minify" is: right before you start testing the
script. [...]
Right. And when the test fails, you go fix the bug ... wait a minute,
*you can't*.

And why on earth not?
Well, let's say testing shows that there's an error in line 42 of the
minified code that you want to fix. You could attempt to beautify the
minified code again and then compare with the original non-minified code,
but, to begin with, how can you know that even the lines numbers are the
same then?
PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Nov 19 '08 #36
On Nov 19, 5:45*pm, Michael Wojcik <mwoj...@newsguy.comwrote:
Jorge wrote:
On Nov 17, 9:32 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
Jorge wrote:
>This is ridiculous:
"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."
And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.
Yes, Wojcik, that's a good question, because most UAs "Accept-
encoding: gzip" nowadays: these are the numbers:
.js: 64592 chars.
.js: 43286 chars. (minified).
.js.gz: 14229 bytes. (gzipped).
.js.gz: 11561 bytes. (minified + gzipped).

Thanks. That's a useful data point.
OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.

Depends on what tradeoff developers want to make, of course, which *in
turn probably ought to depend on what targets they're optimizing for.

If you're optimizing for devices with constrained resources (such as
mobile phones), then that 20KB of cache space might justify
minimization. If you're optimizing for really slow links, the 3KB of
additional data transfer might justify it.

If you're optimizing for users with lots of resources who might want
to read the source, you don't want to minimize. If you're concerned
about the possibility (however remote) of transformation effects, you
don't want to minimize.
You forgot this one: if the server doesn't support HTTP compression or
if you're optimizing for UAs that don't accept-encoding:gzip, the 20k
of additional data transfer might justify it.

--
Jorge.
Nov 19 '08 #37
On Nov 19, 7:14*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
(...)
many people (and it seems especially those that use minifiers)
don't know how to write scripts properly (...)
ROTFL

--
Jorge.
Nov 19 '08 #38
On Nov 19, 7:19*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
Well, let's say testing shows that there's an error in line 42 of the
minified code that you want to fix. *You could attempt to beautify the
minified code again and then compare with the original non-minified code,
but, to begin with, how can you know that even the lines numbers are the
same then?
Too complicated for you.

--
Jorge.
Nov 19 '08 #39
On Nov 19, 1:19*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
The answer to "when to minify" is: right before you start testing the
script. [...]
Right. *And when the test fails, you go fix the bug ... wait a minute,
*you can't*.
And why on earth not?

Well, let's say testing shows that there's an error in line 42 of the
minified code that you want to fix. *You could attempt to beautify the
minified code again and then compare with the original non-minified code,
but, to begin with, how can you know that even the lines numbers are the
same then?
Is this supposed to be a joke? For one, save the original
(obviously.) For two, who debugs by line number?
Nov 19 '08 #40
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
The answer to "when to minify" is: right before you start testing the
script. [...]
Right. And when the test fails, you go fix the bug ... wait a minute,
*you can't*.
And why on earth not?
Well, let's say testing shows that there's an error in line 42 of the
minified code that you want to fix. You could attempt to beautify the
minified code again and then compare with the original non-minified code,
but, to begin with, how can you know that even the lines numbers are the
same then?

Is this supposed to be a joke?
No.
For one, save the original (obviously.)
When you can't be sure whether the error that occurred in the minified code
also occurs in the original code in the first place, or the problem is the
result of the minifying instead, saving the original code is not of much
help when finding a problem in the minified code.
For two, who debugs by line number?
OK, so how do you suggest to debug a one-liner that is the result of the
minifying of, say, 500+ LOCs? And even if you could do that *always*, I
seriously doubt you can look at one example of p,a,c,k,e,d code junk and
tell me at once which identifier in it means which in the original code,
because obfuscation is one result of this kind of minifying. Then we have
the issue of semicolon insertion or parenthesizing that needs to be done
explicitly in minified code but not in the original code. And probably I
have forgotten something else.
PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Nov 19 '08 #41
On Nov 19, 5:04*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
The answer to "when to minify" is: right before you start testing the
script. [...]
Right. *And when the test fails, you go fix the bug ... wait a minute,
*you can't*.
And why on earth not?
Well, let's say testing shows that there's an error in line 42 of the
minified code that you want to fix. *You could attempt to beautify the
minified code again and then compare with the original non-minified code,
but, to begin with, how can you know that even the lines numbers are the
same then?
Is this supposed to be a joke?

No.
For one, save the original (obviously.)

When you can't be sure whether the error that occurred in the minified code
also occurs in the original code in the first place, or the problem is the
result of the minifying instead, saving the original code is not of much
help when finding a problem in the minified code.
Perhaps you are just snake-bit, but I have never found such an error.
Before testing, I run the code through JSLint and then the YUI
"minifier." Invariably, the code runs exactly as before. If it ever
did not, I would find the problem easily enough. Thanks for your
concern though.
>
For two, who debugs by line number?

OK, so how do you suggest to debug a one-liner that is the result of the
minifying of, say, 500+ LOCs? *And even if you could do that *always*, I
What difference does it make how many lines of code there are (if you
are not debugging by line number?)
seriously doubt you can look at one example of p,a,c,k,e,d code junk and
Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
think I use it?
tell me at once which identifier in it means which in the original code,
because obfuscation is one result of this kind of minifying.
Again, there is no need to track down bugs in the minified code. If
there ever were, perhaps I would get a new minifier.

*Then we have
the issue of semicolon insertion or parenthesizing that needs to be done
explicitly in minified code but not in the original code. *And probablyI
have forgotten something else.
I already covered that (JSLint.) (The semicolons, etc., not whatever
you forgot.)
Nov 19 '08 #42
David Mark meinte:
Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
think I use it?
Your penchant for jQuery makes you a prime contender.

Gregor
Nov 19 '08 #43
Jorge wrote:
On Nov 19, 5:45 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
>Jorge wrote:
>>On Nov 17, 9:32 pm, Michael Wojcik <mwoj...@newsguy.comwrote:
Jorge wrote:
This is ridiculous:
"Cutting 30k by gzipping is allright, but cutting 20k by minifying
isn't."
And how much larger is the file if you just gzip, and don't minify?
Frequent strings of repeated spaces ought to find a pretty high place
in the LZ table.
Yes, Wojcik, that's a good question, because most UAs "Accept-
encoding: gzip" nowadays: these are the numbers:
.js: 64592 chars.
.js: 43286 chars. (minified).
.js.gz: 14229 bytes. (gzipped).
.js.gz: 11561 bytes. (minified + gzipped).
Thanks. That's a useful data point.
>>OTOH, the non-minified script that ends up into the browser's memory
still weights (unnecessarily) +20k more than the minified version:
IOW, it both takes longer to transmit and occupies 50% more memory
once received. Is it a "don't care" ? I don't think so. YMMV.
Depends on what tradeoff developers want to make, of course, which in
turn probably ought to depend on what targets they're optimizing for.

If you're optimizing for devices with constrained resources (such as
mobile phones), then that 20KB of cache space might justify
minimization. If you're optimizing for really slow links, the 3KB of
additional data transfer might justify it.

If you're optimizing for users with lots of resources who might want
to read the source, you don't want to minimize. If you're concerned
about the possibility (however remote) of transformation effects, you
don't want to minimize.

You forgot this one: if the server doesn't support HTTP compression
thenchange to one that does ;-)
or
if you're optimizing for UAs that don't accept-encoding:gzip, the 20k
of additional data transfer might justify it.
Thats fair enough.

there are other tradeoffs too..using a style sheet MAY help if you are
constantly sending similar style information.

Using more javascript subroutines if you constantly do similar things
all over the code.
--
Jorge.
Nov 19 '08 #44
On Nov 19, 6:09*pm, Gregor Kofler <use...@gregorkofler.atwrote:
David Mark meinte:
Nobody, but nobody, uses that stupid p,a,c,k,e,r. *What makes you
think I use it?

Your penchant for jQuery makes you a prime contender.
I see. I could cleverly deflate all of that incompetent code that
didn't belong in my application in the first place to lighten the
impact of my incompetence. That could work!
Nov 20 '08 #45
On Nov 19, 11:04*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
>
OK, so how do you suggest to debug a one-liner that is the result of the
minifying of, say, 500+ LOCs? *And even if you could do that *always*, I
seriously doubt you can look at one example of p,a,c,k,e,d code junk and
tell me at once which identifier in it means which in the original code,
(...)
minified !== obfuscated: JSMin: http://fmarcia.info/jsmin/test.html

--
Jorge.
Nov 20 '08 #46
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>Thomas 'PointedEars' Lahn wrote:
David Mark wrote:
Thomas 'PointedEars' Lahn wrote:
>David Mark wrote:
>>The answer to "when to minify" is: right before you start
>>testing the script. [...]
>Right. And when the test fails, you go fix the bug ... wait a
>minute, *you can't*.
And why on earth not?
Well, let's say testing shows that there's an error in line 42 of
the minified code that you want to fix. You could attempt to
beautify the minified code again and then compare with the original
non-minified code, but, to begin with, how can you know that even
the lines numbers are the same then?
[...]
>>For one, save the original (obviously.)
When you can't be sure whether the error that occurred in the minified
code also occurs in the original code in the first place, or the
problem is the result of the minifying instead, saving the original
code is not of much help when finding a problem in the minified code.

Perhaps you are just snake-bit,
Sorry, I don't follow.
but I have never found such an error.
That does not mean anything.
Before testing, I run the code through JSLint and then the YUI
"minifier." Invariably, the code runs exactly as before. If it ever did
not, I would find the problem easily enough. Thanks for your concern
though.
>>For two, who debugs by line number?
OK, so how do you suggest to debug a one-liner that is the result of
the minifying of, say, 500+ LOCs? And even if you could do that
*always*, I

What difference does it make how many lines of code there are (if you are
not debugging by line number?)
The debuggers that I have encountered so far work line-based (e.g., set a
breakpoint on or go to line #n, not statement #n). There are a few that can
beautify the code before debugging to make debugging easier (among them
Venkman), but not all.
>seriously doubt you can look at one example of p,a,c,k,e,d code junk
and

Nobody, but nobody, uses that stupid p,a,c,k,e,r.
Experience and Google hits disagree. There are 1'620 Google hits for
'"p,a,c,k,e,r" javascript", 1'930 for '"p,a,c,k,e,d" javascript'
as of today.
What makes you think I use it?
I did not imply that. You deem yourself to be too important.
>tell me at once which identifier in it means which in the original
code, because obfuscation is one result of this kind of minifying.

Again, there is no need to track down bugs in the minified code. If
there ever were, perhaps I would get a new minifier.
You cannot know that. You said before that you tested the *minified* code.
But that code differs from the original code. So you cannot know (until it
is too late) that minifying caused you additional problems.
>Then we have the issue of semicolon insertion or parenthesizing that
needs to be done explicitly in minified code but not in the original
code. And probably I have forgotten something else.

I already covered that (JSLint.) (The semicolons, etc., not whatever you
forgot.)
JSLint has problems of its own, as has been demonstrated recently. Suffice
it to say that even JSLint cannot recognize when parenthesizing or explicit
semicolon insertion was necessary in the minified version of the analyzed
code, because that is not only a matter of syntax, but also of semantics.
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Nov 20 '08 #47
Gregor Kofler wrote:
David Mark meinte:
>Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
think I use it?

Your penchant for jQuery makes you a prime contender.
Aren't you confusing David with, uhm, somebody else?
PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 20 '08 #48
Thomas 'PointedEars' Lahn meinte:
Gregor Kofler wrote:
>David Mark meinte:
>>Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
think I use it?
Your penchant for jQuery makes you a prime contender.

Aren't you confusing David with, uhm, somebody else?
Definitely not. Should I have added a ;-) then?

Gregor
Nov 20 '08 #49
Gregor Kofler wrote:
Thomas 'PointedEars' Lahn meinte:
>Gregor Kofler wrote:
>>David Mark meinte:
Nobody, but nobody, uses that stupid p,a,c,k,e,r. What makes you
think I use it?
Your penchant for jQuery makes you a prime contender.
Aren't you confusing David with, uhm, somebody else?

Definitely not. Should I have added a ;-) then?
Ahh, there:

| (X) TypeError: this.ironyDetector is not a function
| File: stressed/usenet.js
| Line: 42
\\// PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>
Nov 20 '08 #50

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sql-db2-dba | last post by:
Does DB2 just fudge it when it is an empty table? Is there a "formula" for average row size when you have variable length records. Or you really have to know what your application is packing into...
4
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
5
by: AAguiar | last post by:
I have an asp.net project where the code behind the aspx page calls a c# class which makes calls to a managed static C++ class. The C# class works fine when the asp net worker process starts, when...
8
by: Galina | last post by:
Hello I have 6 dependent list boxes on my ASP page:  Faculty;  Lecturer;  Course;  Course occurrence;  Group;  Week commencing date. When faculty is selected, lists of lecturers and...
32
by: David Mark | last post by:
I've got a collection of functions that accept a function or object (paired with a method name) as a callback. For the longest time I have relied on this test. (typeof cb == 'function') ...
0
by: shapper | last post by:
Hello, Does anyone knows any C# Library to Combine and Minify CSS and Javascript files? I was able to find a few Rails and Java tools but no .NET tool. This would be really useful for ASP.NET...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.