Unused services in the client controller
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
a month ago
Hello! I'm checking some widgets and in the client controller, there are services being injected but were not used, for example the $http. This also applies to OOB widgets. What could be the possible reason behind it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @Momiji
This is a good observation. Seeing unused services injected in client controllers (like $http) is pretty common in ServiceNow widgets, even OOB ones. A few reasons why this happens:
In OOB or custom widgets, unused services (like $http) appear because:
-
Legacy code – it was used earlier, later removed.
-
Standard injection pattern – added for convenience in customization.
-
Future-proofing – kept in case upgrades need it.
It causes no issues, but you can remove them for cleaner code.
If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!
Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI
ï”— YouTube: https://www.youtube.com/@learnservicenowwithravi
ï”— LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
1. Some of them were used earlier and SN upgraded the code but it was not removed.
2. SN could use them in future.
Note : From health scan perspective if there are unused parameters in the function, they are flagged as healthscan finding , you can remove unused parameters from custom/customised functions.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Momiji ,
As per servicenow official docs,
Remove unused Angular Providers from client script For easier maintenance, remove any unused Angular Providers that were injected into the client script function statement. They didn't make any sense.
Shashank Jain