Start your All-Access Pass to unlock this challenge
In this video, we've added a weather widget snippet to our page and saw how it only works the first time our page loaded. When we clicked on subsequent pages, it stopped working!
Why?
Because the <script> tag that our snippet of code adds to <head> is only added once, due to a check made by the code itself, and only executes once.
<script>
<head>
Because the <script> tag added by our snippet of code to <head> is added multiple times but only executed once since there is no full page load when we are navigating using Turbo Drive.
Because Turbo recognizes similar scripts between page views and avoids re-executing them between page views.
The widget snippet worked as expected. It did not stop working after subsequent page views: we even verified that the a tag was present!
a