I have a javascript code that should only run in app/Clients/show_products.ctp
$(document).ready(function(){ //Do stuff }); Should I to put this in layout or in the end of the view?
Put it in the app/Clients/show_products.ctp view, using scriptBlock
$this->Html->scriptBlock(' $(document).ready(function(){ //Do stuff }); '); You can specify to display the code inline or not. If you need it in more than one places, you can use an element
Adding it on the bottom of the view would be ok.
If you have a lot of code, it's better to create a js file for it.