You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
| 1. | Document-Object Model (DOM), DOM manipulation |[Reading W1](/Week1/README.md)|[Homework W1](/Week1/MAKEME.md)|[Lesson Plan W1](/Week1/LESSONPLAN.md)|
| 1. | Document-Object Model (DOM), DOM manipulation |[Reading W1](/Week1/README.md)|[Homework W1](/Week1/MAKEME.md)|[Lesson Plan W1](/Week1/LESSONPLAN.md)|
38
+
| 2. | Developer tools, Web Storage, Event Loop, Callbacks |[Reading W2](/Week2/README.md)|[Homework W2](/Week2/MAKEME.md)|[Lesson Plan W2](/Week1/LESSONPLAN.md)|
39
+
| 3. | SPA vs. MPA, Scope, Closures |[Reading W3](/Week3/README.md)|[Homework W3](/Week3/MAKEME.md)|[Lesson Plan W3](/Week1/LESSONPLAN.md)|
A browser is software that allows you to access websites.
24
+
A web browser is software that allows you to access websites.
24
25
25
26
### How a browser works
26
27
27
-
[How a web browser functions](https://www.youtube.com/watch?v=z0HN-fG6oT4)
28
+
In your journey into becomeing a web developer it's important to know the tools you'll be using intimately. One such is the browser, which will be used to display your websites. In the following resources you'll learn about the many parts any web browser consists of and what their use is:
29
+
30
+
-[How a web browser functions](https://www.youtube.com/watch?v=z0HN-fG6oT4)
31
+
-[How do web browsers work?](https://medium.com/@monica1109/how-does-web-browsers-work-c95ad628a509)
32
+
33
+
### Different browsers work differently
34
+
35
+
A website, ultimately is a set of instructions describing how a series of webpages should look. It's up to the browser to render it by reading the code from your HTML/CSS and JavaScript files. There are, however, differences in the code interpretation of the different browsers, thus making the output look differently.
36
+
37
+
That's why you should check the way your website looks on different browsers during the development of your website. This is called making it **cross browser compatible**>
38
+
39
+
You can use the following online tool in order see how your pages look on multiple browsers:
40
+
41
+
-[Browsershots](http://browsershots.org)
42
+
43
+
A good website should look and function the same in any browser.
44
+
45
+
Unfortunately, there is no easy solution for that. You should check the specificities of each browser that fails to display your website correctly and make the necessary adjustments to your code. Such compatibility issues may occur not only in different browsers but because of an old browser version which does not support completely the latest standards.
46
+
47
+
This is because browser development doesn't go at the same speed as programming language development. More often than not, the web technologies you're using will have more features you as a developer can make use of than the browser can currently handle. This is important to keep in mind.
48
+
49
+
When you do your styling, especially, it's important to know if a certain browser (and browser version) is even able to understand it. A helpful tool in identifying this is a website called **caniuse.com**:
50
+
51
+
-[caniuse](https://caniuse.com/)
52
+
-[Check HTML5/CSS3 Support with CANIUSE.COM](https://www.youtube.com/watch?v=el7McMP8CB8)
53
+
54
+
Generally speaking, you want to support as many browsers (and browser versions) with your code as possible.
55
+
56
+
For more research, check out the following resources:
57
+
58
+
-[Dealing with Cross Browser Compatibility](https://www.youtube.com/watch?v=9tEixRJ3GeI)
59
+
-[Understanding The Stacking Context for Cross Browser Compatibility](https://medium.com/@mattcroak718/understanding-the-stacking-context-for-cross-browser-compatibility-2b21db1cf621)
28
60
29
61
## 2. What is the Document-Object Model (DOM)?
30
62
@@ -42,51 +74,97 @@ For our purposes, it's only important to understand that the browser looks at Ja
42
74
43
75
-[JavaScript, the Browser, and the DOM](https://www.youtube.com/watch?v=31ViueuIXGE)
44
76
45
-
## The DOM
77
+
### The DOM
78
+
79
+
The Document-Object Model (DOM) is a tree-like representation of the structure of a webpage. The following is a simple example:
80
+
81
+

46
82
47
83
JavaScript is made accessible to the DOM by embedding it into an HTML file. You might've seen the <script></script> before; well, this is how the browser becomes aware of JavaScript.
48
84
49
85
-[What exactly is the DOM](https://bitsofco.de/what-exactly-is-the-dom/)
50
86
-[JavaScript and the browser](https://eloquentjavascript.net/13_browser.html)
51
87
52
-
## The Critical Rendering Path
88
+
###The Critical Rendering Path
53
89
54
90
The actual process of transforming HTML, CSS and JavaScript into a user-viewable version of a webpage is called **the Critical Rendering Path**.
55
91
56
92
-[Understanding the Critical Rendering Path](https://bitsofco.de/understanding-the-critical-rendering-path/)
57
93
58
-
### Traversing the DOM
94
+
## 3. What is DOM Manipulation?
95
+
96
+
**DOM manipulation** refers to the activity of selecting and modifying DOM elements. The main reason why this is done is that **you want to show the user different things depending their activity**, for example:
97
+
98
+
- You click on a [hamburger menu icon](https://bit.ly/2Yr4O7Z) and a navigation menu slides in
99
+
- You scroll down and the elements of
100
+
101
+
Finding the right elements is called **traversing the DOM**. Traversing the DOM essential means: using JavaScript to select certain elements within the DOM in order to modify them (change color, size or make them disappear, for example).
102
+
103
+
### Manipulating elements
104
+
105
+
Look at the following code sample:
106
+
107
+
```js
108
+
constbody=document.querySelector('body'); // you can also use 'document.body'
109
+
constnewParagraph=document.createElement('p');
110
+
newParagraph.innerText='This paragraph will be added to the body!';
111
+
newParagraph.style.background='red';
112
+
body.appendChild(newParagraph);
113
+
```
114
+
115
+
In this example we're executing the following steps:
59
116
60
-
Traversing the DOM essential means: using JavaScript to select certain elements within the DOM in order to modify them (change color, size or make them disappear, for example). The modification of elements is also known as **DOM manipulation**.
117
+
1. We're first selecting the body: this is always necessary, as we can only add or remove elements from the body of the document
118
+
2. Secondly, we're creating a new DOM element: a <p> element
119
+
3. Thirdly, we're injecting content into the element
120
+
4. Fourthly, we give our element a background color
121
+
5. Finally, we add the <p> element in the body
61
122
62
-
Learning how to write JavaScript that targets the DOM is an essential part of being a web developer. In the following resources
123
+
Test this code out by copying and pasting it in the Developer Console of your browser. After you've pressed the Enter/Return key you will find your new <p> at the end of the page!
124
+
125
+
Learning how to write JavaScript that targets the DOM is an essential part of being a web developer. In the following resources you'll more about how to do that:
63
126
64
127
-[Traversing the DOM with JavaScript](https://zellwk.com/blog/dom-traversals/)
65
128
-[JavaScript DOM Crash Course - Part 2](https://www.youtube.com/watch?v=mPd2aJXCZ2g)
66
129
67
-
## 3. What is DOM Manipulation?
68
-
69
130
### Browser events
70
131
71
-
Browser events are very much like real-life events: they are important things that happen. In real-life this could be getting a job, graduating from school or receiving a birthday gift. In terms of the browser, this is much more small scale: user actions like `clicking`, `scrolling` or `typing` are all considered events.
132
+
Browser events (also known as DOM events) are very much like real-life events: they are important things that happen. In real-life this could be getting a job, graduating from school or receiving a birthday gift. In terms of the browser, this is much more small scale: user actions like `clicking`, `scrolling` or `typing` are all considered events.
133
+
134
+
These events are important to know about, because based on those we manipulate the DOM. For example, user clicks on an image and as a result it increases in size.
72
135
73
-
These events are important to know about, because based on those we manipulate the DOM. It's cause and effect: user clicks on an image and as a result it, for example, increases in size.
136
+
Effectively it's cause and effect.
137
+
138
+
Check out the following resources to learn more about what events there are, and what you can do to manipulate elements after an event has happened:
74
139
75
140
-[What are browser events?](https://www.youtube.com/watch?v=LeKKU3a4AQo)
141
+
-[Introduction to browser events](https://javascript.info/introduction-browser-events)
76
142
-[JavaScript DOM Crash Course - Part 3](https://www.youtube.com/watch?v=wK2cBMcDTss)
77
143
78
144
### Event listeners and handlers
79
145
80
-
The process of DOM manipulation happens in three steps:
146
+
Take a look at this code:
147
+
148
+
```js
149
+
constbody=document.querySelector('body');
150
+
body.addEventListener('click', function() {
151
+
body.style.background='black';
152
+
});
153
+
```
154
+
155
+
Test this code out by copying and pasting it in the Developer Console of your browser. After you've pressed the Enter/Return click the website. You should see the whole <body> becoming black!
156
+
157
+
This is DOM manipulation in its simplest form. It goes in three essential steps:
81
158
82
-
(1) an event happens ("User clicks on a button")
83
-
(2) JavaScript is aware and looking for this specific user action
84
-
(3) JavaScript modifies the DOM as a result ("The button disappears and is replaced by an image")
159
+
(1) An event happens ("User clicks on the page")
160
+
(2) JavaScript is aware and looks for this specific user action (The browser is listening for the event*), in this case a `click` event)
161
+
(3) JavaScript modifies the DOM as a result (\_A function that makes the body background color black is executed*)
85
162
86
-
The second step is called **listening for the event**. We do this by using a by the browser predefined function called `addEventListener()`, which we get from the `document` object.
163
+
The second step is called **listening for the event**. We do this by using a by the browser predefined function called `addEventListener()`, which we get from the `document` object in the browser. The browser needs to listen to the event in order to know what it should do ("make the body background color black") in case a certain event (`click`) happens to a certain element (`body`).
87
164
88
165
The third and final step is called **handling the event**. The term "handler" effectively means "taking care of" the event; the response to the event. The handler itself is nothing more than a function that executes more JavaScript code in order to manipulate a particular part of the page (either the element that experienced the event or a totally different part of the page).
89
166
167
+
-[Events in JavaScript](https://www.youtube.com/watch?v=7UstS0hsHgI)
Copy file name to clipboardExpand all lines: Week2/MAKEME.md
+9-18Lines changed: 9 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -11,24 +11,7 @@
11
11
12
12
## **2. JavaScript exercises**
13
13
14
-
## **3. Code along**
15
-
16
-
-[Building a Real-World Application](https://www.youtube.com/watch?v=NYq9J-Eur9U)
17
-
18
-
## **4. PROJECT:**
19
-
20
-
```
21
-
Topics discussed this week:
22
-
• Functions + JSON/Arrays
23
-
• Array Manipulations
24
-
• JSON
25
-
• Map and filter
26
-
• Arrow functions
27
-
```
28
-
29
-
> [Here](/Week3/README.md) you find the readings you have to complete before the third lecture.
30
-
31
-
## Step 1: More map, filter and `=>`
14
+
# Step 1: More map, filter and `=>`
32
15
33
16
_Deadline Wednesday_
34
17
@@ -114,6 +97,14 @@ Follow these steps. Each step should build on the result of the previous step.
114
97
- Choose variable and parameters names that most accurately describe their contents or purpose. When naming an array, use a plural form, e.g. `durations`. For a single item, use a singular form, e.g. `duration`. For details, see [Naming Conventions](https://github.com/HackYourFuture/fundamentals/blob/master/fundamentals/naming_conventions.md).
115
98
- Don't forget to use `=>`.
116
99
100
+
## **3. Code along**
101
+
102
+
-[Building a Real-World Application](https://www.youtube.com/watch?v=NYq9J-Eur9U)
103
+
104
+
## **4. PROJECT:**
105
+
106
+
#
107
+
117
108
## Step 2: Testing your homework
118
109
119
110
We have provided _unit tests_ in this repo that allow you to verify that your homework produces the expected results.
0 commit comments