Lesson # 4 How to put JavaScript Code in a separate file? I ❤ Steemit

in #programming7 years ago

log2o.jpg
All the time's good time and we continue our course on JavaScript programming

Today we'll talk about such a topic as taking out the code in a separate file. I think this was invented for the convenience of writing code and generating a script because if in one file there were millions of lines of code that would be responsible for different functions, we would easily get very confused in this code and The file weight would be very large and not convenient to use!

And so let's go!

To make a separate JavaScript code file, you need to register a couple of code that connects to HTML
capture(39).png
In general, this code itself

Now I will explain a little

Sink /path/to/script.js is the path where the file is located

You can also specify a link to the file for example:
capture(40).png
And when your page opens, HTML will ask you to read this file that you connected with this code.

As far as I know that in HTML write only simple scripts and more complex ones already transfer to a separate file a good plus that the browser downloads itself to the cache this file and when your page is reopened it will open up much faster than the first time because the data of the script Already stored in the cache.

I think on this we will end today there is no opportunity to write more tomorrow will be a lesson on the topic Asynchronous scripts all thank you lesson is calculated for beginners who are learning the language programming all the benefits to you)

Reference to the last lesson https://steemit.com/programming/@kostiayatsuk/lesson-3-hello-steemit-com

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 62629.89
ETH 2572.37
USDT 1.00
SBD 2.74