22
edits
m (→First test) |
|||
Line 11: | Line 11: | ||
Here is a simple first test to see how the attribute works. The following lines are in the <tt>head</tt> element of a page : | Here is a simple first test to see how the attribute works. The following lines are in the <tt>head</tt> element of a page : | ||
&# | <script> | ||
var test1 = "Test 1 : fail"; | var test1 = "Test 1 : fail"; | ||
&# | </script> | ||
&# | <script <font style="color: green;">defer</font>> | ||
console.log(test1); | console.log(test1); | ||
&# | </script> | ||
&# | <script> | ||
test1 = "Test 1 : pass"; | test1 = "Test 1 : pass"; | ||
&# | </script> | ||
If the <tt>defer</tt> attribute for the <tt>script</tt> element is correctly implemented in the browser which renders the page, the second script element is executed after all the others, and the [https://addons.mozilla.org/en-US/firefox/addon/1843 Firebug] console should display <tt><font style="color: blue;">"Test 1 : pass"</font></tt>.<br> Otherwise, the console displays <tt><font style="color: blue;">"Test 1 : fail"</font></tt> because the scripts are executed in the same order than in the source code. | If the <tt>defer</tt> attribute for the <tt>script</tt> element is correctly implemented in the browser which renders the page, the second script element is executed after all the others, and the [https://addons.mozilla.org/en-US/firefox/addon/1843 Firebug] console should display <tt><font style="color: blue;">"Test 1 : pass"</font></tt>.<br> Otherwise, the console displays <tt><font style="color: blue;">"Test 1 : fail"</font></tt> because the scripts are executed in the same order than in the source code. |
edits