I am calling the javascript function in the view of an layout. I have a common layout for different views but there are 2 views in specifically i want to check the `screen width`. In layout i can define the script but they will work on my whole application so just i want to mention them specifically in 2 views. I could have make 2 javascript files and include them in their respective views but i think this is not a good option.

How will i approach to this issue?

i have two views `mobile-view` and `desktop-view`.