Unused services in the client controller

Momiji
Tera Contributor

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?

3 REPLIES 3

Ravi Gaurav
Giga Sage
Giga Sage

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:

  1. Legacy code – it was used earlier, later removed.

  2. Standard injection pattern – added for convenience in customization.

  3. 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/

RaghavSh
Kilo Patron

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

Shashank_Jain
Kilo Sage

@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.

 

If this works, please mark it as helpful/accepted — it keeps me motivated and helps others find solutions.
Shashank Jain