Naming Anonymous JavaScript Functions

371 views
Skip to first unread message

John J Barton

unread,
Apr 28, 2011, 11:26:46 AM4/28/11
to Firebug
A preprint of Salman Mirghasemi's work on function naming is
available:
http://blog.getfirebug.com/2011/04/28/naming-anonymous-javascript-functions/

jjb

Pedro Simonetti Garcia

unread,
Apr 28, 2011, 12:16:31 PM4/28/11
to fir...@googlegroups.com
That's awesome! I saw a message you posted on Orion Dev newsgroup recently asking about JavaScript parsers and I was about to ask you what for would we use a parser in Firebug, but now everything is clear.

Naming anonymous functions is such a useful feature. I can't to see it working!

Congratulations guys!

Pedro Simonetti.


2011/4/28 John J Barton <johnj...@johnjbarton.com>

--
You received this message because you are subscribed to the Google Groups "Firebug" group.
To post to this group, send email to fir...@googlegroups.com.
To unsubscribe from this group, send email to firebug+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/firebug?hl=en.


Rob Campbell

unread,
Apr 28, 2011, 12:37:07 PM4/28/11
to fir...@googlegroups.com
how many of the surveyed anonymous functions implemented a displayName property on them?

John J Barton

unread,
Apr 28, 2011, 4:00:00 PM4/28/11
to Firebug


On Apr 28, 9:37 am, Rob Campbell <robmcampb...@gmail.com> wrote:
> how many of the surveyed anonymous functions implemented a displayName
> property on them?

As far as I am able to figure out, one library Cappicino and one
cross compiler OpenLaszlo use displayName. We did not happen to use
those in our study. More information is available on
http://code.google.com/p/fbug/issues/detail?id=1811.

The displayName approach is fine for some users who use those
libraries or who wish to invest time in naming functions but for some
reason don't want to use names in function declarations. Salman's work
allows development tools to support every user in some way without
extra work on their part.

jjb

Donny Viszneki

unread,
Apr 29, 2011, 6:07:26 PM4/29/11
to Firebug
I'm doing work with JavaScript software transformation (JavaScript
source code in, different JavaScript source code out) using JavaScript
to implement the software transformation process :)

If it is possible to trap and modify JavaScript code before it is
parsed by the web browser, it would be extremely trivial to give
advisory names (naming a function expression, for instance) to all
functions.

In a product I am working on now, I end up writing out long advisory
names to every function, and if I get it wrong, or overlook a needed
change when using existing code as a template for new code, then it
can become very misleading.

So, is it possible or nearly possibly to trap and modify JavaScript
code before the browser parses it?

On Apr 28, 4:00 pm, John J Barton <johnjbar...@johnjbarton.com> wrote:
> On Apr 28, 9:37 am, Rob Campbell <robmcampb...@gmail.com> wrote:
>
> > how many of the surveyed anonymous functions implemented a displayName
> > property on them?
>
> As far as I am able to figure out, one library  Cappicino and one
> cross compiler OpenLaszlo  use displayName.   We did not happen to use
> those in our study. More information is available onhttp://code.google.com/p/fbug/issues/detail?id=1811.

John J Barton

unread,
Apr 29, 2011, 9:57:53 PM4/29/11
to Firebug


On Apr 29, 3:07 pm, Donny Viszneki <donny.viszn...@gmail.com> wrote:
> I'm doing work with JavaScript software transformation (JavaScript
> source code in, different JavaScript source code out) using JavaScript
> to implement the software transformation process :)
>
> If it is possible to trap and modify JavaScript code before it is
> parsed by the web browser, it would be extremely trivial to give
> advisory names (naming a function expression, for instance) to all
> functions.
>
> In a product I am working on now, I end up writing out long advisory
> names to every function, and if I get it wrong, or overlook a needed
> change when using existing code as a template for new code, then it
> can become very misleading.
>
> So, is it possible or nearly possibly to trap and modify JavaScript
> code before the browser parses it?

This is usually done with a proxy. You may also be able to intercept
the network traffic in the browser. But Firefox does not support
intercepting the JS.

jjb

Kevin Dangoor

unread,
Apr 29, 2011, 10:27:53 PM4/29/11
to fir...@googlegroups.com
On Fri, Apr 29, 2011 at 9:57 PM, John J Barton <johnj...@johnjbarton.com> wrote:
This is usually done with a proxy. You may also be able to intercept
the network traffic in the browser. But Firefox does not support
intercepting the JS.


Feel free to file a bug on this, if you don't spot one in bugzilla already (this is directed at Donny). I can imagine there being some neat things that can be done if script execution could be intercepted.

Kevin

--
Kevin Dangoor

work: http://mozilla.com/
email: kdan...@mozilla.com
blog: http://www.BlueSkyOnMars.com
Reply all
Reply to author
Forward
0 new messages