title: Load Accordian Panel on click rather than page load
body: <p>I am using a Google Map and Street View javascript code within two panels using Bootstrap Accordian. The first panel contains the map and the second contains the street view. Currently both panels load their JS code on page load but the second panel is collapsed so only the Map panel is visible. </p>
  
  <p>Is it possible to delay the loading of the second panel which contains the street view code until the user clicks to expand/unhide the content rather than loading it all on page load? </p>
  
  <p>Thanks</p>
  
  <pre><code>&lt;div class="panel-group" id="accordion"&gt;
  &lt;div class="panel panel-default"&gt;
  &lt;div class="panel-heading"&gt;
  &lt;h4 class="panel-title"&gt;
  &lt;a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion"
  href="#collapse1"&gt;Local Map&lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;
  &lt;div id="collapse1" class="panel-collapse collapse in"&gt;
  &lt;div class="panel-body"&gt;
  **Google Map JS**
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="panel panel-default"&gt;
  &lt;div class="panel-heading"&gt;
  &lt;h4 class="panel-title"&gt;
  &lt;a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" 
  href="#collapse2"&gt;Street View&lt;/a&gt;&lt;/h4&gt;&lt;/div&gt;
  &lt;div id="collapse2" class="panel-collapse collapse"&gt;
  &lt;div class="panel-body"&gt;
  &lt;div id="pano" style="width: 400px; height: 300px;"&gt;&lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;script src="https://maps.googleapis.com/maps/api/js?v=3.exp&amp;sensor=false"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  $(document).ready(function(){
  $(".accordion-toggle").on('click',function(){
  if($(this).attr('href') =="#collapse2"){
  alert('');function initialize() {
  var point= new google.maps.LatLng(51.524964,-0.34146399999997357);
  var panoramaOptions = {
  position: point,
  pov: {
  heading: 12.399999999999999,
  pitch: 6.94
  }
  };
  var panorama = new     
  google.maps.StreetViewPanorama(document.getElementById('pano'),panoramaOptions);
  map.setStreetView(panorama);
  }
  google.maps.event.addDomListener(window, 'load', initialize);
  }
  });
  });
  }
  });
  });
  &lt;/script&gt;
  </code></pre>