10x10 HTML5 Script Tag

633 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
633
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

10x10 HTML5 Script Tag

  1. 1. HTML5 <script> Tag Michelle Fowler MW Art2830 Web Design
  2. 2. Supported by All Major Browsers
  3. 3. Definition of <script> Tag● Is used to define a client-side script, such as a JavaScript● Element either contains scripting statements or it points to an external script file through the "src" attribute
  4. 4. <script>Example: http://homepage.cs.uri.edu/book/javascript/javascript.htm
  5. 5. Attributeshttp://w3schools.com/html5/tag_script.asp
  6. 6. async AttributeExample: ● <script type="text/javascript" src="demo_async.js" async=" async"></script> ● <script async="async">The async attribute is a boolean attribute, and can be set in thefollowing ways: ● <script async> ● <script async="async"> ● <script async="">Not supported by Internet Explorer
  7. 7. defer AttributeExample: ● <script type="text/javascript" src="demo_defer.js" defer=" defer"></script> ● <script defer="defer">The defer attribute is a boolean attribute, and can be set in thefollowing ways: ● <script defer> ● <script defer="defer"> ● <script defer="">
  8. 8. src AttributeExample: ● <script type="text/javascript" src="demo_time.js"></script> ● <script src="URL">Possible values: ● An absolute URL - points to another web site (like src="http://www.example.com/example.js") ● A relative URL - points to a file within a web site (like src="/scripts/example.js")
  9. 9. Differences Between HTML 4.01 & HTML5● The "type" attribute is required in HTML 4, but optional in HTML5● The "async" attribute is new in HTML5● Some HTML 4.01 attributes are not supported in HTML5
  10. 10. Tips and Notes● If the "src" attribute is present, the <script> element must be empty● There are several ways an external script can be executed: ○ If async = "async": the script will be executed while the page continues the parsing ○ If async is not present and defer = "defer": the script is executed when the page has finished parsing ○ If neither async or defer is present: the script is fetched and executed immediately, before the browser continues parsing the page

×