Posts

Showing posts from August, 2007

global scope evaluation and DOM investigation

After precedent post I prefer to write another one about global scope evaluation and kentaromiura question: does your evalScript proposal cause DOM side effects? Before I post my test code that shows how a medium or big page, about 5000 divs or paragraphs, is not affected by my proposal (about 0.09 delay over 1000 evalScript interactions) I would talk about global scope evaluation. What does it mean: global scope evaluation? Every time we use a function to evaluate a string, temporary scope is injected into code evaluation. While some library (in this case I talk about jQuery ) uses stranges (imho) partial (wrong) solutions to remove nested scope from evaluation, I can tell You that everything You need to use a clear scope is to call another function, where this reference is just super object (window if executed inside a browser). This is an elementary example: function clearScopeEvaluation(data){ return eval(data); }; // just call them everywhere ... (function(a){ clearScopeEvalu

A better JavaScript code evaluation?

Yesterday Ajaxian published a benchmark using Flex and comparing them with Ajax JSON, Dojo and other way to transfer data between client and server. Interesting point is not that kind of bench (imho) but one comment wrote by Albert Kühner: A question about AJAX-JSON: Is there a performance difference if you dynamically create a script tag which loads a generated js file in which all objects are serialized to JavaScript objects (like JSON but without having to eval() the XHR response)? It seems to be a simple and basic question but He was right because the answer is: yes , a script tag is generally interpreted faster than code evaluation using eval, execScript or Function constructor. I suppose the reason is quite obvious: eval, as execScript or Function, brings temporary local scope inside evaluated code and this cause a little overhead while a script tag is always interpreted only inside global scope (window or super object). This should be a limit for evaluation common usage (ofte

SWF Activation using Flash Satay method

Long long IT time ago (2002) A list Apart wrote about a new W3 markup compatible way to show SWF files in a web page using a method called Satay . This was my favourite one to create valid (x)HTML pages and this method is unobtrusive too, allowing alternative content directly inside object tag without JavaScript requirement. This method is able to send common informations inside SWF too, using a "sentinel" file or directly full SWF to load. Since Internet Explorer 6 add a new ActiveX control that requires at least one click before user can use SWF content many developers wrote different libraries to fix this problem, present on IE 7, Opera 9 and probably other browsers. These libraries are good enough to solve "activation click" problem but these often offer more features we (at least me) need. This is why I've just uploaded my last tiny library to solve this problem, compatible with IE6, 7, Opera 9, FireFox 1.5+, Safari 2+ and many other browsers. Its size? A