As I am trying to figure out why the loading process of my webpage (dxview) takes so long, I decided to put some console.log()
statements in both the code before and after an eval()
(part of that process) and the string inside that very eval()
. It looks somewhat like this:
console.log("Timestamp before eval: " + (new Date().getTime()));
eval("... console.log('Some log in here'); ...");
console.log("Timestamp after eval: " + (new Date().getTime()));
Interestingly, the result was in another order than I expected:
"Timestamp before eval: 1423852110738"
"Timestamp after eval: 1423852110787"
"Some log in here"
This makes it very hard to detect the actual time consuming part as using timestamps this way does not even indicate whether the eval
is the problem.
Putting logs at the beginning and end of the eval'ed string indicate that the eval
actually takes 250 to 350 ms to process while the difference between the two timestamps is just 49 ms. But until the viewShown
method is invoked, it takes another 23,000+ ms.
AFAIK, if you don't use web workers or timeouts/intervals, JS should continue with the code just after (and not before) a statement is done. I might be confusing something here, but how could this work then?
Kind regards,
jaySon