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":
Optimization never comes for free. Watch out for the side effects it may brings.
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.