View
1.508
Download
7
Embed Size (px)
DESCRIPTION
This is a talk given by Ian Selby at SF JS #3 about server side JavaScript and the power of maintaining a DOM on the server-side for manipulation there.
Citation preview
Server Side Javascript
Make Your JavaScript More Gooder!
Server Side Javascript
Make Your JavaScript More Gooder!
Ian SelbyWeb Developer, Gen X Design & Aptana
www.gen-x-design.com
What isServer-Side JavaScript?
What isServer-Side JavaScript?and, why you should be excited about it.
Server-Side JavaScript (SSJS) is:
Server-Side JavaScript (SSJS) is:
JavaScript That GetsExecuted on the Server!
However,This opens the door forsome really cool things...
However,This opens the door forsome really cool things...
•Access to databases
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system•Access to system commands
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system•Access to system commands
•Server-side DOM
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system•Access to system commands
•Server-side DOM•File uploads
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system•Access to system commands
•Server-side DOM•File uploads•Server-side XHRs
However,This opens the door forsome really cool things...
•Access to databases•Access to the file system•Access to system commands
•Server-side DOM•File uploads•Server-side XHRs•and (of course), much more...
So,
Why Should You be Excited?
... beyond the fact I said you should.
Because...
Because...
•You’re already a JavaScript Ninja!
Because...
•You’re already a JavaScript Ninja!•Your current skills become much more valuable.
Because...
•You’re already a JavaScript Ninja!•Your current skills become much more valuable.•You can support non-JavaScript clients.
Because...
•You’re already a JavaScript Ninja!•Your current skills become much more valuable.•You can support non-JavaScript clients.
•There aren’t cross-browser issues on the server.
Because...
•You’re already a JavaScript Ninja!•Your current skills become much more valuable.•You can support non-JavaScript clients.
•There aren’t cross-browser issues on the server.•You don’t really need to learn anything new!
Because...
•You’re already a JavaScript Ninja!•Your current skills become much more valuable.•You can support non-JavaScript clients.
•There aren’t cross-browser issues on the server.•You don’t really need to learn anything new!
... and, JavaScript is a darn cool language!
So, what options do youhave?
There are two mainplayers...
Mozilla Rhino
Aptana Jaxer
Rhino•Open-source•JavaScript for Java•Developed by Mozilla
•Runs on the JVM•Allows binding to Java objects and libraries•Allows you to run JS from the shell
www.mozilla.com/rhino
Jaxer•Open-source•Based on Mozilla Firefox 3 code base
www.aptana.com/jaxer
Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana
www.aptana.com/jaxer
Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana
•Runs in Apache or Jetty
www.aptana.com/jaxer
Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana
•Runs in Apache or Jetty•Provides a server-side DOM & browser
www.aptana.com/jaxer
Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana
•Runs in Apache or Jetty•Provides a server-side DOM & browser•Works with existing JavaScript libraries
www.aptana.com/jaxer
Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana
•Runs in Apache or Jetty•Provides a server-side DOM & browser•Works with existing JavaScript libraries•Plays well with existing server-side languages
www.aptana.com/jaxer
Some Other SSJS Projects...
App JetRecently announced and launched SSJS
solution.
Looks promising, but appears to be somewhat limited at the moment. Has some nice APIs tho, worth a
look!www.appjet.com
PhobosProject Phobos is a lightweight,
scripting-friendly, web application environment running on the Java
platform.
More of a framework, and actually runs on Rhino. Still considered experimental, but a good project
nonetheless.
https://phobos.dev.java.net
Right,
Let’s take a look at some examples...
Jaxer examples... I don’t know Java!
Jaxer Image Gallery
http://jxrgallery.aptanacloud.com
Jaxer Image Gallery•Uses sessions•Reads images from file
system•Uses JS file uploads•Works with PHP for
image manipulation
http://jxrgallery.aptanacloud.com
Simple Vote/Poll
http://jxrpoll.aptanacloud.com
Simple Vote/Poll•Uses JS library server-
side (jQuery)•Server-side DOM
manipulation•E4X as a templating
system•Database & session
goodness
http://jxrpoll.aptanacloud.com
DOM Scraping
http://jxrdomscraper.aptanacloud.com
DOM Scraping•Uses Jaxer.Sandbox•Uses new Firefox 3
goodness (getElements ByClassName, built in XPath, etc.)
•Good leverage of client-side async mixed to invoke server-side code
http://jxrdomscraper.aptanacloud.com
That’s It!
That’s It!For more information and to ask any
questions, visit my blog:
www.gen-x-design.com
Source Code for all examples will be posted there in the near future.
Slide design inspired by Amy Hoy: www.slash7.com
To download Jaxer, visit www.aptana.com/jaxer