How to remove a js file from view

Hi friends,

As you know there are many files auto included in the head like CSS / JS. On some pages, those may not be required.
I am also stuck in a situation where the HTML element id doesn’t exist on the page but the js is already loaded in head so throwing the js error continuously because the element id doesn’t exist on that specific view.
Can anyone please tell me how can I remove any unwanted JS / CSS files from a specific view?


Hi Vishal,
There is no any shortcut for this problem. You need to specify CSS/JS in your layout those are common for all pages and add individual CSS/JS to view files those are using it. This will also increase your page performance.

Hi Kailash,

Thanks for your immediate response.

Yes, I know including unnecessary files in head affect the page performance but the project which i am working on is not a fresh one, this is an enhancement project. So to include the common files in head and rest files in specific view is itself a challenging task hence wanted to know if there any html helper remove method (or any other trick) exist in cake.


Sorry, there are no any trick.