[Service Portal] Javascript libraries included (OOB)
In Service Portal, many libraries are included and loaded by default in all pages.To avoid overloading the platform with duplicate libraries, first consult the existing.
There is a trick to recover it.
1. Inspect the code of the page
2. Search the DOM for the string: "/scripts/js_includes_sp.jsx"
3. Open the path of this JSX file in the browser (ex: https://xxxx.service-now.com/scripts/js_includes_sp.jsx?v=11-22-2017_2104&lp=Fri_Dec_15_13_37_09_CET...).
The JS code is displayed :
/*! RESOURCE: /scripts/js_includes_sp.js */
/*! RESOURCE: /scripts/js_includes_sp_deps.js */
/*! RESOURCE: /scripts/lib/jquery/jquery-2.1.js */
(function( global, factory ) {
if ( typeof module === "object" && typeof module.exports === "object" ) {
module.exports = global.document ?
factory( global, true ) :
function( w ) {
if ( !w.document ) {
}
...
To retrieve the scripts list, isolate all lines / *! RESOURCE: ... * / .
In Notepad ++ :
4. Do "Ctrl" + "F"
5. Search : "/ *! RESOURCE "
6. Click on the "Mark" tab
7. Check the "Bookmark line" cache
8. Click on "Mark All"
All lines are marked
9. Click on "Search> Bookmark> Copy Bookmarked Lines"
10. Open a new file and paste the result
11. It just remains to delete "/ *! RESOURCE: "and" * / "(Find + Replace All)
We get the final list :
/scripts/js_includes_sp.js
/scripts/js_includes_sp_deps.js
/scripts/lib/jquery/jquery-2.1.js
/scripts/angular_includes_no_min.1.5.11.js
...
Before include a new JS library (ex : lodash), search it in this list ![]()
Regards
https://www.servicenow.com/community/developer-articles/service-portal-javascript-libraries-included-oob/ta-p/2327947