I'm not sure why this would reduce memory consumption in V8 -- naturally, V8's parser already disregards comments and whitespace, like any JS engine would.
So I would say the right place for such functionality is a minifier/"uglifier" script that developers can run over their code before shipping it on the web. That way, it also reduces download size. Many such minifiers exist already. Looking at the details of your plan, two issues come to mind: (1) Removing newlines from JavaScript is generally not semantics-preserving due to the language's "automatic semicolon insertion" feature. (2) Regular expressions cannot reliably detect comments in JavaScript, because the language's syntax is more complex than regular expressions can handle. Detecting comments in JS requires a tokenizer that's aware of JS semantics. On Sat, Apr 30, 2022 at 11:28 PM Aashish Rangwalla <arangwa...@gmail.com> wrote: > Hi all, > I am considering writing a small piece of code that uses regular > expressions to remove all comments and newlines from JS code. This could > possibly reduce the memory consumption of V8. Has this already been > implemented and where would I put this code? > Thanks, > S. Rangwalla > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-users/d5cadd6f-104d-4e8c-a62c-eebbbc837f70n%40googlegroups.com > <https://groups.google.com/d/msgid/v8-users/d5cadd6f-104d-4e8c-a62c-eebbbc837f70n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CAKSzg3TNkGGtHdDvfCbGv6%3DBDAgO01RLuFsWMV0K8_ubNEVq%3Dw%40mail.gmail.com.