Tuesday, July 10th, 2007

JavaScript running to the server

Category: JavaScript

JavaScript continues to get more talk on the server (yes, years after Netscape Enterprise Server!).

John Resig spent a weekend hacking in the zone, to bring the browser to the server.

This resulting environment allows you to do interesting things such as:

Screen scraping


  1. load("env.js");
  2. window.location = "http://alistapart.com/";
  3. window.onload = function(){
  4.  load("dist/jquery.js");
  5.  print("Newest A List Apart Posts:");
  6.  $("h4.title").each(function(){
  7.    print(" - " + this.textContent);
  8.  });
  9. };

Web Framework


  1. window.onload = function(){
  2.   print("Content-type: text/html\n");
  3.   if ( location.href == "/" )
  4.      show_home();
  5.   print( document.innerHTML );
  6. };
  7. function show_home(){
  8.   document.load("index.html");
  9.   document.getElementById("time").innerHTML = (new Date()).toString();
  10. }

Tom Insam and Ash Berlin also created mod_js, which is a very simple JS embed. Others pointed out mod_wxjs, haxe, and the like.

The beat goes on.

Posted by Dion Almaer at 9:24 am

3.8 rating from 28 votes


Comments feed TrackBack URI

The same is the very core principle of http://www.widgetplus.com and the widgets there, which are all database driven serverside widgets, and the coding behind them – on the server – is javascript and it’s mimicking the browsers DHTML enviroment almost o the letter.

Comment by mikael bergkvist — July 10, 2007

The guys over at http://www.wxjavascript.net have a mod_wxjs Apache module which gives you the server-side Javascript. Also, http://www.whitebeam.org has a whole Javascript-based server-side environment.

In any case, I personally prefer SpiderMonkey implementations to Rhino ones.

Comment by Berislav Lopac — July 10, 2007

simile is using a headless firefox as a server, for its crowbar scraper daemon. with the existing serverside JS stuff sucking ( i mean, writing JS in JAVA is just not fast, sorry..) and Tamarin coming, it will be neat to see this concept mature to the point of more robust usability

Comment by carmen — July 10, 2007

The problem with haxe is that its JavaScript implementation is ActionScript 2.0-ish, being heavily based on the concept of classes. To quote a quote from bash.org, ActionScript is like C#, Java, and Visual Basic had a threesome, and did not use protection. I personally find ActionScript less refreshing than JavaScript.

Comment by kourge — July 11, 2007

It may be a little uncomfortable seeing actual class stuff coming in to the picture – but without it people are going to have a really hard time finding good counter arguments to :


for bigger enterprise-y type projects. Maybe that’s not where it should be used (js2), but if it works it sounds potentially kind of fun..

Comment by Jesse Kuhnert — July 11, 2007

Leave a comment

You must be logged in to post a comment.