title: cakephp how to add script to view
body: <p>I wish to add some script to a view and have it que and load at the bottom of the page within the default layout. At the moment it runs before query is loaded and causes an error.</p>
  
  <p>I am using cakephp 2.5</p>
  
  <p>Is there a way to buffer it?</p>
  
  <p>myview.ctp:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    FWDEVPUtils.onReady(function(){
  
    FWDEVPlayer.useYoutube = "yes";
    FWDEVPlayer.videoStartBehaviour = "pause";
  
    new FWDEVPlayer({   
      //main settings
      instanceName:"player",
      parentId:"player",
      mainFolderPath:"content"
    });
  });
  </code></pre>
  
  <p></p>
  
  <p>default.ctp</p>
  
  <pre><code>echo $this-&gt;Html-&gt;script('//code.jquery.com/jquery-1.10.2.min.js');
  echo $this-&gt;Html-&gt;script('bootstrap.min');
  echo $this-&gt;Html-&gt;script('FWDEVPlayer');
  
  echo $this-&gt;fetch('script');
  echo $this-&gt;Js-&gt;writeBuffer();
  </code></pre>