Archive

Posts Tagged ‘optimization’

Mysterious JavaScript function call failure and loading optimization

January 21st, 2007 No comments

Optimize Your Scripts in DHTML Using the DEFER Attribute

When, for example, a perfect JavaScript function call foo() with the correct syntax is always mysteriously ignored, watch out for the side effect of script loading optimization. The root cause turned out to be that the script that contains the foo() function is loaded like the the following with "defer":

<script src="foo.js" type="text/javascript" defer> </script>

//foo.js
function foo() {
    document.write("hello");
}

Optimization never comes for free. Watch out for the side effects it may brings.

Categories: Web Tags: , ,