V8 on the server

66 views
Skip to first unread message

weblivz

unread,
Sep 2, 2008, 3:54:09 PM9/2/08
to v8-users
As the V8 engine is standalone could it be used for parsing web
documents on the server?

Does it have full DOM and XML DOM support for server parsing?

Furthermore would it scale as a server side parsing solution or is it
built with a client engine in mind (much like the IE javascript
engine) ?

cheers,
steven
http://livz.org

Christian Plesner Hansen

unread,
Sep 2, 2008, 4:08:22 PM9/2/08
to v8-users
The standalone V8 can only be used to execute JavaScript, there is no
DOM implementation. V8 would scale to server side use, but you would
have to add DOM support yourself (or take it from chrome).

weblivz

unread,
Sep 2, 2008, 4:24:07 PM9/2/08
to v8-users
Thanks Christian. I look forward to seeing how it progresses - perhaps
DOM support will come at some point.

cheers,
steven
http://livz.org

KyleJ

unread,
Sep 2, 2008, 4:54:32 PM9/2/08
to v8-users
I was able to get DOM support with this:
http://ejohn.org/blog/pure-javascript-html-parser/

On Sep 2, 1:24 pm, weblivz <webl...@hotmail.com> wrote:
> Thanks Christian. I look forward to seeing how it progresses - perhaps
> DOM support will come at some point.
>
> cheers,
> stevenhttp://livz.org

weblivz

unread,
Sep 2, 2008, 6:33:04 PM9/2/08
to v8-users
Thanks Kyle. Looks interesting.

weblivz

unread,
Sep 3, 2008, 5:44:37 AM9/3/08
to v8-users
Christian - I slept over this and have a follow up question (http://
weblivz.blogspot.com/2008/09/v8-chrome-and-dom.html)

"Most of the scripts i write either use the DOM (getElementById) or
the Xml Dom (childNodes[0].nodeValue) and so on. That is a LARGE part
of my scripts.

So if the engine does not provide support for this, what happens to my
scripts? Do they go really fast until they need to query the DOM and
then slow down? The net effect in my case could be a lot of slowing
down. I my experience, querying the DOM is the slowest part of your
scripts (unless you write non-typical).."

regards,
steven
http://livz.org

Feng Qian

unread,
Sep 3, 2008, 10:28:24 AM9/3/08
to v8-u...@googlegroups.com
Hi Steven,

Let me correct a few things in your blog.

1) you are right that V8 does not provide DOM;
2) Chrome has DOM in the browser because actual implementation is done in WebKit (C++ code);
3) when we talk about DOM and JavaScript in general, we are talking about accessing DOM in JavaScript, we call it language binding (between JavaScript and C++);

So, you can not access DOM in a standalone V8 because DOM is part of browser, (think about it is a library, and only browser implements that library). But you can execute your script in Chrome which has DOM binding with V8.

Your original question was to parse webpages with scripts (using V8 as a parser). It should be fine as long as scripts are not running.

Cheers,
Feng
Reply all
Reply to author
Forward
0 new messages