HTML 4.01 defines an attribute named deferfor the <script>element. The purpose of deferis
to indicate that a script won’t be changing the structure of the page as it executes
Example:
<!DOCTYPE html>
<html>
<head>
<title>Example HTML Page</title>
<script type=”text/javascript” defer src=”example1.js”></script>
<script type=”text/javascript” defer src=”example2.js”></script>
</head>
<body>
<!-- content here -->
</body>
</html>
defer attribute was added beginning with Internet Explorer 4, Firefox 3.5, Safari 5, and Chrome 7. All other browsers simply ignore this attribute and treat the script as it normally would. For this reason, it’s still best to put deferred scripts at the bottom of the page.
For XHTML documents, specify the defer attribute as defer=”defer”
Không có nhận xét nào:
Đăng nhận xét