As the sun rises in the UK, this is half the business shut down during business hours.
406 karma · joined October 16, 2013
As the sun rises in the UK, this is half the business shut down during business hours.
Perhaps in some very conservative societies.
Where I live I'm confident that a boy who enthusiastically engages in things which actually interest him is at a social advantage over boys who halfheartedly pretend to enjoy in whatever his parents think is normal.
Ballet, for sure. Maybe not dresses so much, at least not if he is doing the wearing, but having an interest in the clothes of his female peers certainly isn't any kind of social problem.
For small messages on fast networks there really isn't very much time to save, so for this worst case in terms of looking for somewhere to optimise I think it is best to aim for no significant performance impact. The best improvements are where the messages are very large, on slow networks, or where the server can write out a stream.
The XHR2 spec specifies "While the download is progressing, queue a task to fire a progress event named progress about every 50ms or for every byte received, whichever is least frequent"
Because of "whichever is the least frequent", for messages that take less than 50ms from first byte to last, Oboe.js will get only one callback from the browser and notify all callbacks from inside the same frame of Javascript execution. This is exactly what we want it to do since it avoids rendering happening between the callbacks which would be very bad for overall download time.
I'm in two minds if Oboe should be dropped in to replace JSON AJAX calls, because everything will be accessed from a slow network one day, or if it should be used only for the very large, streamed REST responses.
https://github.com/jimhigson/oboe.js#reading-from-any-stream...
oboe( fs.createReadStream( '/home/me/secretPlans.json' ) )
.node('!.schemes.*', function(scheme){
console.log('Aha! ' + scheme);
});
.node('!.plottings.*', function(deviousPlot){
console.log('Hmmm! ' + deviousPlot);
})
.done(function(){
console.log("*twiddles mustache*");
});Nothing gets parsed more than once. SAX parsers already parse streams, they're just not used very much because they're a pain to program with.
Here's the little test service I wrote to stream out some gzipped content:
https://github.com/jimhigson/oboe.js/blob/master/test/stream...
Firefox's xhr fires progress events for gzipped content but not Chrome's. Looking to see if I can find a way round it.
For most sites there'll be some users where it will make it faster (mobile, slow internet) and others that it'll be about the same. If the network is unreliable it should help as well because when the connection drops you don't lose what you already downloaded.
"makers" = just me :-)
Adding XML/XPATH support would be a natural extension.
The client side works in Node right now as well as in the browser but it is a bit browser-y. It is on my home office Agile board to make it a bit more node-y.
I built this for more-or-less standard downloading, only quicker. But, yeah, if you set a server up to feed it you could use it for lots of creative things.
1 Create XHR, listen to XHR2 progress event. 2 Use Clarinet.js SAX parser, scoop up all events. 3 From SAX events, build up actual JSON and maintain path from root to actual node. 4 Match that path (+ some other stuff) against registered JSONPath specs. 5 Fire callbacks if they pass.
Very similar except JSON/JSONPath instead of HTML/CSS. Oboe runs fine in Node but I want to make the code a bit more standards-y. Ie, using Node's EventEmitters instead of the little pubsub I made for the browser.
There's a test explicitly for not allowing this:
https://github.com/jimhigson/oboe.js/blob/master/test/specs/...
https://github.com/dscape/clarinet
Unquoted JSON in docs is a mistake. I'll take a look now.
I got the idea for this project working on data vis. Not all of the data was visible and we wanted to display the first bit of data quicker without waiting for all of it to arrive. We could have just sent the visible bit but it was good to have some data ready in the off-screen section for when the user scrolled.
Before that I worked on a service where we were aggregating 6 or 7 services into a single JSON. Some of the services were quicker than others but because the AJAX lib we were using waited for the whole response they all had to go at the speed of the slowest component.
We could have done multiple requests but it was more elegant to serve a whole page's json in one call. Also, we cached the slow services so they were only sometimes slow.
Consider if you are writing data from a db: you can either collect all the rows together then write them out, or you can write them out one at a time as you get them. If you write one at a time you are in a sense streaming even if you're not using a streaming protocol.
On a slow network reading any http is like a stream because you can use the first bit to arrive without waiting for the rest. The faster the network the less the benefit but it shouldn't end up worse.
Having said that, there's a much bigger improvement if you're progressively writing out the JSON rather than doing it in one big lump.
If I were buying again I'd get 8GB.