Are there any solutions for running JavaScript on the server to render data for clients with poor support?
-
I'd like to use JavaScript on the client to generate interactive SVG. But some clients (IE) don't support that so I'd also like a fallback that generates a basic static display using the same code running on the server. I suspect I'm not the first to think of this, so does any support already exist? The last thing I am aware of was the "DOM on the server" blog post/hack using, I think, Node.js.
-
Answer:
Raphael.js can render SVG paths in IE. It translates them to VML.
Rick Branson at Quora Visit the source
Other answers
If you want to try Javascript on the server side, evaluate the following: http://github.com/thatcher/rhino-for-webapps This uses Rhino Javascript engine with env.js, which implements browser's window object in javascript. It also supports jquery, so if you are using it, you don't have to change much. I opted for this instead of node.js, because I wanted to have something that can run inside a servlet container as opposed to a standalone service. I tried Ringo.js and Myna.js too. It was a little challenging to get Ringo working on Tomcat and Myna just didn't work. This had no learning curve and worked out of the box. There is very little Java code (in the form of servlets), which was easy to understand, so I can fix something or add features, if need be. Rhino is much slower than V8, but since I am using it for a specific purpose like you and I cache the results, performance is not big a concern for me.
Raghavendra Kidiyoor
You should check out jsdom: http://github.com/tmpvar/jsdom Its (so far) DOM Level 1 for the javascript server. I use it with Node.js but its CommonJS so any (ES5) CommonJS platform should work. I've been working with it for a few weeks now, working on a real-time data-bound DOM-on-the-server concept, and it's been quite satisfactory. jQuery runs on it, and if you use jQuery you can actually get event bubbling for free, which impressed me.
Evan Q Jones
Node.js (http://nodejs.org/) can run Javascript server-side and has a ton of supported modules (http://github.com/ry/node/wiki/modules). Most helpful for your case is jsdom (http://github.com/tmpvar/jsdom) and the Graphics modules (http://github.com/ry/node/wiki/modules#graphics).
Pras Sarkar
If the the question is genuinely about servers rendering javascript on behalf of impoverished clients, there are some direct answers already. If the question is actually about how to deal with SVG on browsers without a good SVG implementation, it's probably best to use some fallback on the client that renders the SVG using Flash or VML in IE. Some examples: svgweb http://code.google.com/p/svgweb/ canvg http://code.google.com/p/canvg/ see http://www.svgopen.org/2010/papers/62-From_SVG_to_Canvas_and_Back/ for more options
Shawn O'Connor
Related Q & A:
- Is that OK to leave a small endless loop script running on server?Best solution by Server Fault
- How to send data from device to remote server?Best solution by Stack Overflow
- How to pass a javascript object back to the server?Best solution by developer.mozilla.org
- How to change column data's as a separate column wise format in a SQL Server?Best solution by stackoverflow.com
- How do plugins identify what type of server a website is running on?Best solution by Stack Overflow
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.