[aklug] Re: Removing newlines from minified javascript

From: Tim Johnson <tim@akwebsoft.com>
Date: Wed Aug 08 2012 - 18:37:25 AKDT

* Michael Fowler <michael@shoebox.net> [120808 17:08]:
> On Wed, Aug 08, 2012 at 11:05:23AM -0800, Tim Johnson wrote:
> > FYI: I am a former C programmer, but years removed. C *should*
> > recognize a newline as ascii 10. C would also recognize an escaped
> > newline as '\n' or ascii 92, ascii 110 (I think).
>
> I was speaking of a literal newline, not an escape sequence. It appears
> JavaScript requires you to escape newlines in strings; for example, this
> is valid code (with surrounding test case):
>
> <html>
> <head><script type="text/javascript">
> function t() {
> alert(
> "hi\
> how are you?\
> good!"
> );
> }
  In this case, I get a "This is an ES5 feature" message, so I am
  alerted. But I'm glad you brought that up. My modified minifier
  would result in the message not being displayed as the author
  meant it. However, it is not something that I would use as a
  general practice. However, I might choose to minify someone else's
  code which might use such a practice. I'm beginning to think that
  I shouldn't be messing with Crockford's approach...
  cheers

-- 
Tim 
tim at tee jay forty nine dot com or akwebsoft dot com
http://www.akwebsoft.com
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Aug 8 18:37:32 2012

This archive was generated by hypermail 2.1.8 : Wed Aug 08 2012 - 18:37:32 AKDT