+ 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?
4 Respuestas
+ 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
+ 4
runs faster when linked (alwayz put ur scripts in head)
+ 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.
+ 2
But anyway better are linked that is sure.