+ 3

Using src versus writing the code

If I place the code at the bottom of the body, would it run smoother if I wrote the entire code, or if I linked the src file?

2nd Jan 2017, 7:05 PM
Caleb Kious
Caleb Kious - avatar
4 Antworten
+ 5
---> link src file instead of of writing code because your browser will cache the js files and thus be able to load the page faster from 2nd time onwards. ---> js code can be divided into 2 parts- 1. initialization - if you need some js code to run before loading the page place a link to that code in <head> before anything else. 2. execution /dynamic nature- This is the functionality you need after the page has been loaded to provide a good user interface. place a link to it at the end of your code just before the closing </body> tag. loading this earlier would only slow down your website as loading js is mostly a blocking call
2nd Jan 2017, 7:30 PM
Caffeinated Gamer YT
Caffeinated Gamer YT - avatar
+ 4
runs faster when linked (alwayz put ur scripts in head)
2nd Jan 2017, 7:07 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 2
Is not necessary tu put scripts into head - in fact according to Google recommendations is better to put them into end of the body because of loading speed.
2nd Jan 2017, 7:27 PM
Ondřej Doněk
Ondřej Doněk - avatar
+ 2
But anyway better are linked that is sure.
2nd Jan 2017, 7:27 PM
Ondřej Doněk
Ondřej Doněk - avatar