News for hackers. Stuff that matters.
Re:Optimizing AngularJS by DigitalSea on Friday November 01, 2013 @01:41AM (#6652000)
When it comes to optimising a Javascript app that involves inserting hundreds and potentially thousands of elements into a page, save yourself headaches and use documentFragment to prevent reflow and at the same time, insert a lot of elements into your page/app very quickly. I recently build an app that has reached almost 54,000 mouse click records. Each time you click, it saves that value in a database: http://coolcoolcoolcoolcool.com/

Inspecting the page will yield a click map where I am displaying all 53,000 mouse clicks inside of a map. As you can see I am using canvas now, but before that I was inserting them into the page and believe it or not, using documentFragment it was amazingly fast.

The reason I switched to canvas because performance on mobile was poor. 53,000+ elements rendered by Javascript on desktop didn't cause any fuss though, using documentFragment makes all the difference. Keep in mind, documentFragment really only shines when you are inserting 1000 plus elements into the page at once. One reflow against many reflows is going to cause you a lot of headaches.

Re:Optimizing AngularJS by thejosh on Friday November 01, 2013 @10:24AM (#6653920)
Sorry dude, I think I just broke your app with a single line of JS.. setInterval(function() {jQuery("#theimage").click()},1);
Re:Optimizing AngularJS by recursive on Friday November 01, 2013 @11:30AM (#6654428)
You can break any web app with a single line of javascript.
Re:Optimizing AngularJS by NKCSS on Friday November 01, 2013 @04:28AM (#6652480)
Your link gives a 502
Re:Optimizing AngularJS by DigitalSea on Friday November 01, 2013 @06:32AM (#6652852)
Haha yeah, it received 12,000 clicks in the space of about 1 hour or so which took it down. Node is good, but it couldn't handle that many clicks.
Re:Optimizing AngularJS by mnutt on Friday November 01, 2013 @09:28AM (#6653512)
Isn't that about 3 clicks a second? Was there a database issue?
Re:Optimizing AngularJS by DigitalSea on Friday November 01, 2013 @06:02PM (#6656790)
It seemed the server at times would get hammered and there would be a kind of race condition happening causing a variable for the clicks I am incrementing to have a value of undefined at times (no idea). I was using nodemon instead of forever.js, so when the error would occur, it wouldn't restart. It's all good now.
Re:Optimizing AngularJS by senorprogrammer on Friday November 01, 2013 @09:49AM (#6653672)
On average. I suspect his clicks were bursty.