Is JavaScript inline possible to achieve?

Is it possible to use JavaScript inline while coding?

Last updated:7/19/2021 5:02:53 AM

1 Answers

Ethan Karla
Ethan Karla

It is possible to use JavaScript anywhere in the whole code but you have to remember the things before adding your script tag anywhere so let's have a look how browser loads a website with <script> tag on it :

Step 1) The website starts fetching content from above.

Step 2) The website will load the content and parse the HTML and render the page.

Step 3) If <script> tag is encountered while parsing it then browser make request for that script file and load that whole library then it should go to second line.

Step 4) Because of that user should experience slow loading of that website and it will be worst experience for user to use that site.

Step 5) So, we need to add the script tag at the end of the file so that the browser first loads the important content of the website which is important for the user and then it switches to the JavaScript.

So, this should clear your confusion.

Happy Coding!

Answer