Why all of us don't like using Javascript externally ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why all of us don't like using Javascript externally ?

Guys , I am new here and don't know why many of us are not implementing the use of the javascript section in web design , instead some of us use it in the HTML section like why ? Why u do dis ? What do you think s ?

30th Jul 2020, 6:35 AM
Siddharth kr.
Siddharth kr. - avatar
13 Answers
+ 6
If you write js externally it might load before html and if you have access any html element in js it won't get it and throw an error that... Can't set property of null. Or Variable ...... Is not defined if you link js at end of body it will load after html and css hence code executed well.
30th Jul 2020, 3:30 PM
Divya Mohan
Divya Mohan - avatar
+ 26
Don't say "all of us" please ...
30th Jul 2020, 6:42 AM
Ipang
+ 12
Calviีฒ i think he meant writing the javascript codes directly on the html page instead of using the javascript section of html on sololearn. yes, that is a bad practice that people do, and you should avoid writing javascript that way. most of them just writes the script tag under body so that it can access the id on the page but they dont realize they can simply use the window.onload handler externally to access them.
30th Jul 2020, 7:26 AM
Shen Bapiro
Shen Bapiro - avatar
+ 8
If you talking about we write JavaScript codes directly on Code playground, that is because of Code playground does not have file structure for us to write external js file. For projects, we are always writing JavaScript codes on external js files .
30th Jul 2020, 7:09 AM
Calviีฒ
Calviีฒ - avatar
+ 6
Umm, "all of us"?
30th Jul 2020, 2:22 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 5
Yes I agree your point. I think internal js for those who have *small js code* on any other editor and he doesn't want to go to wonder btwn file.html,file.css and file.js again and again for frequent updates. This might be possible reason for internal js
30th Jul 2020, 4:24 PM
Divya Mohan
Divya Mohan - avatar
+ 4
Divya Mohan You have valid point about 'errors' but that can not be excuse to use internal JavaScript. it's always good to have your code organized and in sperate folders. You can use onload event if you have to do DOM manipulation.
30th Jul 2020, 4:09 PM
Raj Chhatrala
Raj Chhatrala - avatar
+ 4
๐Ÿ‘‘ Rรณyรฃl KรญnG ๐Ÿ‘‘, please answer only after you have read and understood the question. Your post has no relation to what was asked. https://www.sololearn.com/discuss/1316935/?ref=app
31st Jul 2020, 11:03 AM
HonFu
HonFu - avatar
+ 3
Jaisi Jiski Soch!
30th Jul 2020, 6:41 AM
Lakshay Mittal
Lakshay Mittal - avatar
+ 2
๐Ÿ‘‘ Rรณyรฃl KรญnG ๐Ÿ‘‘ you are very funny ๐Ÿ˜†๐Ÿ˜†, the way you said "we don't like JavaScript" i so touching, where did you think a web developer is going without JavaScript, and who said JavaScript is soo hard to understand? I don't just like JavaScript but i love it. Siddharth kr. not everybody like using inline JavaScript, like me i love using it externally, but in some case i Will use a snippet internally, but one thing about people using inline JavaScript here on sololearn is sometimes because they copied the code somewhere else. or maybe they choice
31st Jul 2020, 12:16 PM
ugochukwu Joseph
ugochukwu Joseph - avatar
+ 2
What do you mean by all of us? I am not one of them and don't like internal js, But still it's the people's option to either use the "<script></script>" or " window.onload = function(){" What's your problem with that?๐Ÿ˜•
1st Aug 2020, 3:33 AM
Bot
Bot - avatar
+ 1
Yeah sorry , I meant writing Javascript on the HTML page and I know writing javascript on the javascript tab is external guys , don't worry I am not that new on SoloLearn ๐Ÿ˜…๐Ÿ˜
30th Jul 2020, 3:45 PM
Siddharth kr.
Siddharth kr. - avatar
0
Anyway it is better so that the html and CSS will run before js or else it can write error
31st Jul 2020, 9:38 PM
Trust Akalonu
Trust Akalonu - avatar