0
<script type="text/javascript">
  (function() {
    var po = document.createElement("script"); po.type = "text/javascript"; po.async = true;
    po.src = "https://apis.google.com/js/plusone.js?publisherid=112917099095075652323";
    var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

<script async src="https://apis.google.com/js/plusone.js?publisherid=112917099095075652323"></script>

Id like to start switching over scripts that are loaded from third parties into the latter syntax. Curious as if the type attribute is even needed. Looking to load all these scripts asynchronously. Thoughts?

dcook
  • 343
  • 1
  • 4
  • 17
  • it's the same, the first is building the script tag using javascript and the second is just using the element itself. the only thing is that the first one is blocking your page for the time it takes it to run – Saar Sep 13 '15 at 19:39
  • Just a little food for thought: Be careful with async loading as there might be dependencies between your scripts. So if you load script A and B asynchronously and A is dependent on B, there will be problems, as it is never guaranteed that one of them will be loaded before the other one! Check out http://stackoverflow.com/questions/2777030/loading-js-files-and-other-dependent-js-files-asynchronously for a solution to this problem **(Link - TL;DR: use LABjs or RequireJS)** – the_critic Sep 13 '15 at 19:47
  • Okay thanks for the insight! The page is pulling 243 requests and I am trying to help this out. – dcook Sep 13 '15 at 20:30
  • Would the page load faster if i were to restructure all the "javascript script building" into just plain – dcook Sep 13 '15 at 20:31

1 Answers1

-1

In your first part of codes, you are actually just creating the same HTTP tag. I think it should be checkable by Chrome or FireFox F12 since the codes there (Chrome F12 - Elements) are processed.

orb
  • 175
  • 2
  • 13