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 ?
14 ответов
+ 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.
+ 26
Don't say "all of us" please ...
+ 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.
+ 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 .
+ 6
Umm, "all of us"?
+ 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
+ 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.
+ 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
+ 3
Jaisi Jiski Soch!
+ 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
+ 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?😕
+ 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 😅😁
0
Anyway it is better so that the html and CSS will run before js or else it can write error