[webkit-dev] EventListener Invocation Cost?

Alex Milowski alex at milowski.org
Sun Jan 9 11:56:08 PST 2011

I'm working on an experiment that uses EventListener instances to
handle a large number of events.  I've noticed there is quite a bit of
overhead when invoking a Javascript-based event listener.

I'm not sure there is a lot that can be done about it.  I've looked
through the implementation of how the Javascript function gets
evaluated.  The only question I have right now is whether the event
handler function from Javascript is JIT compiled.

I'm not sure that really matters.  It seems to be the invocation which
causes the most cost.  If I attach an empty function for the event,
the processing slows down (i.e. the cost is incurred regardless of
what is going on inside the function).  It just seems like the cost of
crossing the language boundary between C++ and Javascript is quite

I've only tried this with JavascriptCore.  I've not looked into
bindings for v8 as of yet.

Thoughts on this?

--Alex Milowski
"The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language

Bertrand Russell in a footnote of Principles of Mathematics

More information about the webkit-dev mailing list