When we get different script, like for google analytics, adsense, or facebook code etc, generally there are 2 scripts.
The first one is an external script tag and the second one some javascript code.
My question: Which is the best way to include these scripts (performance-related)?
I was thinking of including
<script src="//analytics.com/" async defer></script>"`
in <head> , and the js code in a js file, say, main.js, so that it can be cached and minimized with the rest of the javascript.
Would there be any disadvantages of doing this?
If not, (if this is actually better), why everybody is suggesting to put the scripts inside <body> ?
Aucun commentaire:
Enregistrer un commentaire