Update I have discussed this object a part and I agree that the url could be used as unique id as well. In this case the server should use the static url as unique id: StaticJSONP.notify("http://cdn.com/static/article/id.js",{..data..}); So that on client side we can use the simplified signature: StaticJSONP.request( "http://cdn.com/static/article/id.js", function (uid, data) { } ); The callback will receive the uid in any case so that we can create a single callback and handle behaviors accordingly. The script has been updated in order to accept 2 arguments but, if necessary, the explicit unique id is still supported. Under the list of " incomplete and never posted stuff " I found this article which has been eventually reviewed. I know it's " not that compact " but I really would like you to follow the reason I thought about a solution to a not so common, but quite nasty, problem. Back in 2001, my early attempts to include cal...
It is an extremely common task and one of the most used prototype in libraries and applications: Array.prototype.slice The peculiarity of this prototype is to create an Array from an Array like Object such arguments, HTMLCollection, other kind of lists as jQuery results. Every browser, except Internet Explorer, allows direct calls via native prototype obtaining, obviously, best performances. In IE, we have different ways to make this task possible, and these ways are mainly classic loops, or the isArray check to know when it is possible to perform the native call or not. isArray = (function(toString){ return function(obj){ return toString.call(obj) === "[object Array]"; }; })(Object.prototype.toString); Even using a closure, above function could slow down performances, specially in those libraries where Array conversions are performed almost everywhere. As we all know, Internet Explorer behaves weird "sometimes", and one of the weirdest things is tha...
Comments
Post a Comment