59
Server Side Javascript Make Your JavaScript More Gooder!

Ian Selby: Server Side JS (SF JS #3)

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

Page 1: Ian Selby: Server Side JS (SF JS #3)

Server Side Javascript

Make Your JavaScript More Gooder!

Page 2: Ian Selby: Server Side JS (SF JS #3)

Server Side Javascript

Make Your JavaScript More Gooder!

Ian SelbyWeb Developer, Gen X Design & Aptana

www.gen-x-design.com

Page 3: Ian Selby: Server Side JS (SF JS #3)
Page 4: Ian Selby: Server Side JS (SF JS #3)

What isServer-Side JavaScript?

Page 5: Ian Selby: Server Side JS (SF JS #3)

What isServer-Side JavaScript?and, why you should be excited about it.

Page 6: Ian Selby: Server Side JS (SF JS #3)
Page 7: Ian Selby: Server Side JS (SF JS #3)

Server-Side JavaScript (SSJS) is:

Page 8: Ian Selby: Server Side JS (SF JS #3)

Server-Side JavaScript (SSJS) is:

JavaScript That GetsExecuted on the Server!

Page 9: Ian Selby: Server Side JS (SF JS #3)
Page 10: Ian Selby: Server Side JS (SF JS #3)

However,This opens the door forsome really cool things...

Page 11: Ian Selby: Server Side JS (SF JS #3)

However,This opens the door forsome really cool things...

•Access to databases

Page 12: Ian Selby: Server Side JS (SF JS #3)

However,This opens the door forsome really cool things...

•Access to databases•Access to the file system

Page 13: Ian Selby: Server Side JS (SF JS #3)

However,This opens the door forsome really cool things...

•Access to databases•Access to the file system•Access to system commands

Page 14: Ian Selby: Server Side JS (SF JS #3)

However,This opens the door forsome really cool things...

•Access to databases•Access to the file system•Access to system commands

•Server-side DOM

Page 15: Ian Selby: Server Side JS (SF JS #3)

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

Page 16: Ian Selby: Server Side JS (SF JS #3)

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

Page 17: Ian Selby: Server Side JS (SF JS #3)

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...

Page 18: Ian Selby: Server Side JS (SF JS #3)
Page 19: Ian Selby: Server Side JS (SF JS #3)
Page 20: Ian Selby: Server Side JS (SF JS #3)

So,

Why Should You be Excited?

... beyond the fact I said you should.

Page 21: Ian Selby: Server Side JS (SF JS #3)
Page 22: Ian Selby: Server Side JS (SF JS #3)

Because...

Page 23: Ian Selby: Server Side JS (SF JS #3)

Because...

•You’re already a JavaScript Ninja!

Page 24: Ian Selby: Server Side JS (SF JS #3)

Because...

•You’re already a JavaScript Ninja!•Your current skills become much more valuable.

Page 25: Ian Selby: Server Side JS (SF JS #3)

Because...

•You’re already a JavaScript Ninja!•Your current skills become much more valuable.•You can support non-JavaScript clients.

Page 26: Ian Selby: Server Side JS (SF JS #3)

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.

Page 27: Ian Selby: Server Side JS (SF JS #3)

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!

Page 28: Ian Selby: Server Side JS (SF JS #3)

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!

Page 29: Ian Selby: Server Side JS (SF JS #3)
Page 30: Ian Selby: Server Side JS (SF JS #3)
Page 31: Ian Selby: Server Side JS (SF JS #3)

So, what options do youhave?

Page 32: Ian Selby: Server Side JS (SF JS #3)
Page 33: Ian Selby: Server Side JS (SF JS #3)

There are two mainplayers...

Mozilla Rhino

Aptana Jaxer

Page 34: Ian Selby: Server Side JS (SF JS #3)
Page 35: Ian Selby: Server Side JS (SF JS #3)
Page 36: Ian Selby: Server Side JS (SF JS #3)

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

Page 37: Ian Selby: Server Side JS (SF JS #3)
Page 38: Ian Selby: Server Side JS (SF JS #3)
Page 39: Ian Selby: Server Side JS (SF JS #3)

Jaxer•Open-source

www.aptana.com/jaxer

Page 40: Ian Selby: Server Side JS (SF JS #3)

Jaxer•Open-source•Based on Mozilla Firefox 3 code base

www.aptana.com/jaxer

Page 41: Ian Selby: Server Side JS (SF JS #3)

Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana

www.aptana.com/jaxer

Page 42: Ian Selby: Server Side JS (SF JS #3)

Jaxer•Open-source•Based on Mozilla Firefox 3 code base•Developed by Aptana

•Runs in Apache or Jetty

www.aptana.com/jaxer

Page 43: Ian Selby: Server Side JS (SF JS #3)

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

Page 44: Ian Selby: Server Side JS (SF JS #3)

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

Page 45: Ian Selby: Server Side JS (SF JS #3)

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

Page 46: Ian Selby: Server Side JS (SF JS #3)
Page 47: Ian Selby: Server Side JS (SF JS #3)
Page 48: Ian Selby: Server Side JS (SF JS #3)

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

Page 49: Ian Selby: Server Side JS (SF JS #3)
Page 50: Ian Selby: Server Side JS (SF JS #3)
Page 51: Ian Selby: Server Side JS (SF JS #3)

Right,

Let’s take a look at some examples...

Jaxer examples... I don’t know Java!

Page 53: Ian Selby: Server Side JS (SF JS #3)

Jaxer Image Gallery•Uses sessions•Reads images from file

system•Uses JS file uploads•Works with PHP for

image manipulation

http://jxrgallery.aptanacloud.com

Page 55: Ian Selby: Server Side JS (SF JS #3)

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

Page 57: Ian Selby: Server Side JS (SF JS #3)

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

Page 58: Ian Selby: Server Side JS (SF JS #3)

That’s It!

Page 59: Ian Selby: Server Side JS (SF JS #3)

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