# How to remove a js file from view

**URL:** <https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380>\
**Category:** Need Help\
**Created:** [July 16, 2019, 11:03am UTC](https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380 "2019-07-16T11:03:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vishal2811](https://avatars.discourse-cdn.com/v4/letter/v/fbc32d/32.png) [@vishal2811](https://discourse.cakephp.org/u/vishal2811)\
**Post date:** [July 16, 2019, 11:03am UTC](https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380/1 "2019-07-16T11:03:31Z")

</div>

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**?

Thanks.

---

<div class="post-metadata">

**Author:** ![kailashdesk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kailashdesk/32/1493_2.png) [@kailashdesk](https://discourse.cakephp.org/u/kailashdesk)\
**Post date:** [July 16, 2019, 12:17pm UTC](https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380/2 "2019-07-16T12:17:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vishal2811](https://avatars.discourse-cdn.com/v4/letter/v/fbc32d/32.png) [@vishal2811](https://discourse.cakephp.org/u/vishal2811)\
**Post date:** [July 16, 2019, 12:23pm UTC](https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380/3 "2019-07-16T12:23:24Z")

</div>

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.

Thanks.

---

<div class="post-metadata">

**Author:** ![kailashdesk](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/kailashdesk/32/1493_2.png) [@kailashdesk](https://discourse.cakephp.org/u/kailashdesk)\
**Post date:** [July 16, 2019, 12:25pm UTC](https://discourse.cakephp.org/t/how-to-remove-a-js-file-from-view/6380/4 "2019-07-16T12:25:55Z")

</div>

Sorry, there are no any trick.
