js files

HARSHA GOWDA R
Tera Contributor

I have added the following JavaScript libraries to the ServiceNow widget dependencies:
https://d3js.org/d3.v7.min.js
https://unpkg.com/d3-flextree@2.1.2/build/d3-flextree.js
https://unpkg.com/d3-org-chart@3.1.1/build/d3-org-chart.min.js

Is it safe to use these libraries in ServiceNow? Also, could you share the recommended best practices for using external JavaScript libraries within a ServiceNow widget?

1 REPLY 1

meragz
Tera Contributor

Yes, it is generally safe to use these libraries in a ServiceNow widget, provided you are loading them via official Widget Dependencies. Many ServiceNow customers use D3-based visualizations for custom dashboards and organizational charts

 

D3.js (v7): This is the industry standard. It is safe, but be aware that it manipulates the DOM directly. In ServiceNow, if you are using Service Portal (AngularJS), you must ensure D3 doesn't conflict with Angular's lifecycle.

 

Avoid CDN Links in Production

While unpkg.com and d3js.org are fine for development, you should download the .js files and upload them directly to your ServiceNow instance as JS Includes.

  • Security: Prevents "Man-in-the-Middle" attacks if the CDN is compromised.

  • Reliability: Ensures your widget doesn't break if the CDN goes down or changes a version.

  • Performance: Files are served directly from your ServiceNow node.