Skip to content

Commit 52e2819

Browse files
authored
Updated article.md for syntax / grammar
Sorry for the delay!
1 parent e62dfd5 commit 52e2819

File tree

1 file changed

+24
-25
lines changed

1 file changed

+24
-25
lines changed

1-js/02-first-steps/01-hello-world/article.md

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Hello, world!
22

3-
The tutorial that you're reading is about core JavaScript, which is platform-independent. Further on, you will learn Node.JS and other platforms that use it.
3+
The tutorial that you're reading is about core JavaScript, which is platform-independent. Later on, you'll learn about Node.JS and other platforms that use it.
44

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.
5+
But we need a working environment to run our scripts and, since 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). We'll focus on JavaScript in the browser in the [next part](/ui) of the tutorial.
66

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.
7+
So first, let's see how we attach a script to a webpage. For server-side environments (like Node.JS), you can execute the script with a command like `"node my.js"`.
88

99

1010
## The "script" tag
1111

12-
JavaScript programs can be inserted in any part of an HTML document with the help of the `<script>` tag.
12+
JavaScript programs can be inserted into any part of an HTML document with the help of the `<script>` tag.
1313

1414
For instance:
1515

@@ -35,48 +35,47 @@ For instance:
3535
```
3636

3737
```online
38-
You can run the example by clicking on the "Play" button in its right-top corner.
38+
You can run the example by clicking the "Play" button in the right-top corner of the box above.
3939
```
4040

41-
The `<script>` tag contains JavaScript code which is automatically executed when the browser meets the tag.
41+
The `<script>` tag contains JavaScript code which is automatically executed when the browser processes the tag.
4242

4343

44-
## The modern markup
44+
## Modern markup
4545

46-
The `<script>` tag has a few attributes that are rarely used nowadays, but we can find them in old code:
46+
The `<script>` tag has a few attributes that are rarely used nowadays but can still be found in old code:
4747

48-
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
48+
The `type` attribute: <code>&lt;script <u>type</u>=...&gt;</code>
49+
: The old HTML standard, HTML4, required a script to have a `type`. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern HTML standard, HTML5, totally changed the meaning of this attribute. Now, it can be used for JavaScript modules. But that's an advanced topic; we'll talk about modules in another part of the tutorial.
4950

50-
: The old standard HTML4 required a script to have a type. Usually it was `type="text/javascript"`. It's not required anymore. Also, the modern standard totally changed the meaning of this attribute. Now it can be used for Javascript modules. But that's an advanced topic; we'll talk about modules later in another part of the tutorial.
51-
52-
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
53-
: This attribute was meant to show the language of the script. This attribute no longer makes sense, because JavaScript is the default language. No need to use it.
51+
The `language` attribute: <code>&lt;script <u>language</u>=...&gt;</code>
52+
: This attribute was meant to show the language of the script. This attribute no longer makes sense because JavaScript is the default language. There is no need to use it.
5453

5554
Comments before and after scripts.
56-
: In really ancient books and guides, one may find comments inside `<script>`, like this:
55+
: In really ancient books and guides, you may find comments inside `<script>` tags, like this:
5756

5857
```html no-beautify
5958
<script type="text/javascript"><!--
6059
...
6160
//--></script>
6261
```
6362

64-
This trick isn't used in modern JavaScript. These comments were used to hide the JavaScript code from old browsers that didn't know about a `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
63+
This trick isn't used in modern JavaScript. These comments hid JavaScript code from old browsers that didn't know how to process the `<script>` tag. Since browsers released in the last 15 years don't have this issue, this kind of comment can help you identify really old code.
6564

6665

6766
## External scripts
6867

6968
If we have a lot of JavaScript code, we can put it into a separate file.
7069

71-
The script file is attached to HTML with the `src` attribute:
70+
Script files are attached to HTML with the `src` attribute:
7271

7372
```html
7473
<script src="/path/to/script.js"></script>
7574
```
7675

77-
Here `/path/to/script.js` is an absolute path to the file with the script (from the site root).
76+
Here, `/path/to/script.js` is an absolute path to the script file (from the site root).
7877

79-
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.
78+
You can also provide a relative path from the current page. For instance, `src="https://github.com/script.js"` would mean a file `"script.js"` in the current folder.
8079

8180
We can give a full URL as well. For instance:
8281

@@ -95,15 +94,15 @@ To attach several scripts, use multiple tags:
9594
```smart
9695
As a rule, only the simplest scripts are put into HTML. More complex ones reside in separate files.
9796
98-
The benefit of a separate file is that the browser will download it and then store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
97+
The benefit of a separate file is that the browser will download it and store it in its [cache](https://en.wikipedia.org/wiki/Web_cache).
9998
100-
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.
99+
Other pages that reference the same script will take it from the cache instead of downloading it, so the file is actually downloaded only once.
101100
102-
That saves traffic and makes pages faster.
101+
That reduces traffic and makes pages faster.
103102
```
104103

105104
````warn header="If `src` is set, the script content is ignored."
106-
A single `<script>` tag can't have both the `src` attribute and the code inside.
105+
A single `<script>` tag can't have both the `src` attribute and code inside.
107106

108107
This won't work:
109108

@@ -113,7 +112,7 @@ This won't work:
113112
</script>
114113
```
115114

116-
We must choose: either it's an external `<script src="https://github.com/%E2%80%A6">` or a regular `<script>` with code.
115+
We must choose either an external `<script src="https://github.com/%E2%80%A6">` or a regular `<script>` with code.
117116

118117
The example above can be split into two scripts to work:
119118

@@ -127,9 +126,9 @@ The example above can be split into two scripts to work:
127126
128127
## Summary
129128
130-
- We can use a `<script>` tag to add JavaScript code to the page.
129+
- We can use a `<script>` tag to add JavaScript code to a page.
131130
- The `type` and `language` attributes are not required.
132131
- A script in an external file can be inserted with `<script src="path/to/script.js"></script>`.
133132
134133
135-
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.
134+
There is much more to learn about browser scripts and their interaction with the webpage. But let's keep in mind that this part of the tutorial is devoted to the JavaScript language, so we shouldn't distract ourselves with browser-specific implementations of it. We'll be using the browser as a way to run JavaScript, which is very convenient for online reading, but only one of many.

0 commit comments

Comments
 (0)