+ 3

How can I organise my javascript?

The javascript that I include in my Web page doesn't works mod of the time

27th Apr 2020, 3:10 PM
Sketch
Sketch - avatar
10 Réponses
+ 4
Comment your javascript file code because it will make you easier to understand and organise
27th Apr 2020, 3:30 PM
Gone
+ 3
I include javascript in sololearn in JS sololearn playground.
29th Apr 2020, 2:43 AM
Sketch
Sketch - avatar
+ 2
Please elaborate it more.
27th Apr 2020, 3:35 PM
Gone
+ 2
Usually I include javascript in web page linked through <script src = "url.js"><\script> i.e. localy stored in my device
29th Apr 2020, 2:45 AM
Sketch
Sketch - avatar
+ 2
Ruby Kumari I wrote: "in the html tab [ ... ] at the place wich fit to you"... Doesn't make it obvious that could be "in body or head tags" ^^ ?
29th Apr 2020, 6:42 AM
visph
visph - avatar
+ 1
It may be a mistake in linking javascript files to html. It will be good if specify. This problem is on sololearn playground or on your local machine. If you show your attempts. It will be easier for us to answer the question
27th Apr 2020, 3:15 PM
🇮🇳Vivek🇮🇳
🇮🇳Vivek🇮🇳 - avatar
+ 1
You can create another javascript file rather than including in html (body tag) page. Use: <script src = "name.js"></script> In your HTML page.
27th Apr 2020, 3:33 PM
Gone
+ 1
You can add your javascript codes in body or head tags
29th Apr 2020, 6:37 AM
Malmi Yasanthika
Malmi Yasanthika - avatar
0
We need accurate informations to be able to help you: In wich context do you run your web page? If your code run in sololearn code playground, it doesn't work as you could think, for different reasons... How do you include the javascript in your web page? 1) in the sololearn code playground JS tab 2) wrapped in a <script></script> pair tag 3) linked through a <script src="url/to/script.js"></script> empty pair tag (if so, in wich context? sololearn code playground, localy on your device, internet hosting service, what is the 'src' value you set and where is located your script file?)
28th Apr 2020, 1:16 PM
visph
visph - avatar
0
In sololearn code playground context you cannot link external files located on your device ^^ You need to include your JS either in the JS tab (as if it was in a <script></script> at the end of the <head> part of the html tab) or in the html tab, wrapped in a <script> (without src attribute, otherwise that woud cause the js to be ignored), at the place wich fit to you (scripts inserted in the <head> section are executed before DOM ready, so you need to defer execution of code attempting to access the DOM to either an on 'load' or on 'DOMContentLoaded' events ;P)...
29th Apr 2020, 3:46 AM
visph
visph - avatar