Web Front-End Programming
Javascript In the web browser
Where to put your browser-based is a programming language, that has two main uses:
Copyright By Assignmentchef assignmentchef
1. Javascript used to manipulate the DOM in a web browser (discussed in another lecture)
2. Javascript used to write scripts with NodeJS (discussed in another lecture)
Today we are focusing on (1).
More specifically, what are the different ways you can include your Javascript in a page run by a web browser?
HOW code is included
Code can either be included inline (part of the page) or included via external link (URL to resource)
inline external
1
mypage1.html
mypage2.html
1
1 const a = 1 + 2; 2 console.log(a);
HOW code is included
Linking javascript externally:
Improvements performance when browser cache is utilised Reduces the time it takes for initial html document to be received (smaller file)
Placing Javascript inline:
Avoids network requests (potentially costly) for script if file is not yet loaded
WHERE code is included
1 2 3 4 5 6 7 8 9
Generally speaking you can either:
1. Include in the
2. Include at the end of if you need do not need your javascript to run prior to your DOM elements initially rendering
We usually do (2)
CS: assignmentchef QQ: 1823890830 Email: [email protected]
Reviews
There are no reviews yet.