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
Copy file name to clipboardExpand all lines: 1-js/02-first-steps/01-hello-world/article.md
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ The tutorial that you're reading is about core JavaScript, which is platform-ind
4
4
5
5
But, we need a working environment to run our scripts, and, just because this book is online, the browser is a good choice. We'll keep the amount of browser-specific commands (like `alert`) to a minimum, so that you don't spend time on them if you plan to concentrate on another environment like Node.JS. On the other hand, browser details are explained in detail in the [next part](/ui) of the tutorial.
6
6
7
-
So first, let's see how to attach a script to the webpage. For server-side environments, you can just execute it with a command like `"node my.js"` for Node.JS.
7
+
So first, let's see how to attach a script to a webpage. For server-side environments, you can just execute it with a command like `"node my.js"` for Node.JS.
8
8
9
9
10
10
[cut]
@@ -45,7 +45,7 @@ The `<script>` tag contains JavaScript code which is automatically executed when
45
45
46
46
## The modern markup
47
47
48
-
The `<script>` tag has a few attributes that are rarely used nowadays, but we can find them in the old code:
48
+
The `<script>` tag has a few attributes that are rarely used nowadays, but we can find them in old code:
49
49
50
50
The `type` attribute: <code><script <u>type</u>=...></code>
51
51
@@ -70,15 +70,15 @@ Comments before and after scripts.
70
70
71
71
If we have a lot of JavaScript code, we can put it into a separate file.
72
72
73
-
The script file is attached to HTML with `src` attribute:
73
+
The script file is attached to HTML with the `src` attribute:
74
74
75
75
```html
76
76
<scriptsrc="/path/to/script.js"></script>
77
77
```
78
78
79
79
Here `/path/to/script.js` is an absolute path to the file with the script (from the site root).
80
80
81
-
It is also possible to provide a path relative to the current page. For instance, `src="https://github.com/script.js"` would mean a file `"script.js"`from the current folder.
81
+
It is also possible to provide a path relative to the current page. For instance, `src="https://github.com/script.js"` would mean a file `"script.js"`in the current folder.
82
82
83
83
We can give a full URL as well, for instance:
84
84
@@ -99,7 +99,7 @@ As a rule, only the simplest scripts are put into HTML. More complex ones reside
99
99
100
100
The benefit of a separate file is that the browser will download it and then store in its [cache](https://en.wikipedia.org/wiki/Web_cache).
101
101
102
-
After this, other pages which want the same script will take it from the cache instead of downloading it. So the file is actually downloaded only once.
102
+
After this, other pages that want the same script will take it from the cache instead of downloading it. So the file is actually downloaded only once.
103
103
104
104
That saves traffic and makes pages faster.
105
105
```
@@ -134,4 +134,4 @@ The example above can be split into two scripts to work:
134
134
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
135
135
136
136
137
-
There is much more about browser scripts and their interaction with the web-page. But let's keep in mind that this part of the tutorial is devoted to JavaScript language, so we shouldn't distract ourselves from it. We'll be using a browser as a way to run JavaScript, which is very convenient for online reading, but yet one of many.
137
+
There is much more to learn about browser scripts and their interaction with the web-page. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves from it. We'll be using a browser as a way to run JavaScript, which is very convenient for online reading, but yet one of many.
0 commit comments