Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it fundamentally wrong to write a CPU intensive client side HTML5 application? [closed]

It is possible and sensible to plan on writing a client side HTML5 Application that will be doing some CPU intensive calculations? (Image processing)

I know that it's usually has been the standard to offload calculations to the server but since there are new options with HTML5 i'm wondering if we could actually write a full app that will run in the browser.

If I understand correctly, web workers can help with multi-threading tasks but I have no deep knowledge of how that exactly works.

Again, I'm looking for leads on how to approach this, if at all.

Thanks!

like image 790
Ben Avatar asked Dec 12 '13 06:12

Ben


2 Answers

No, it is not fundamentally wrong. Client machines typically have a lot of processing power, and this power is at the browsers disposal. Just make sure you write your app in such a way that it has a good user experience!

Web workers will allow your UI JavaScript to run while you number-crunch on another thread. This sounds quite appropriate for your task.

Also, by doing this client-side your app no longer depends on the network connectivity to the server. With image processing I would expect that there will be a lot of data passing from client to server, which could be quite slow.

like image 87
ColinE Avatar answered Oct 19 '22 12:10

ColinE


It's possible, it's even been done but whether it's a good idea or not depends entirely on the context - who's going to be using it, what browsers would it need to support, what devices would it need to run on.

Should you want to go ahead, one thing to checkout would be asm.js it's a subset of javascript (so it works in all browsers) that browsers can optimize very well for (I think just Firefox right now) you can either code as if to the metal in it or more sensibly use it as a compile target - so you can write in another language (say C++) - and compile to something that'll run very fast in the browser.

like image 37
Tom Avatar answered Oct 19 '22 12:10

Tom