Use LWS Trusted Mode to Elevate Third-Party Scripts
Trusted mode allows you to elevate third-party scripts outside Lightning Web Security so that you can use those scripts in your components. JavaScript that’s uploaded into static resources is elevated to execute directly in the global window context, outside the LWS sandbox. In that context, code runs without distortions from LWS or security wrappers from Lightning Locker. Normally the global context is the exclusive realm of code developed by Salesforce.
Some popular third-party libraries require access to the global context, and LWS or Lightning Locker security restrictions prevent you from using them in Salesforce. Now you can use such libraries by configuring them for LWS trusted mode at the org level and in component code. The third-party code can then execute in the global context.
Enabling trusted mode allows third-party scripts (each a "Non-SFDC Application") to run without the security restrictions that LWS and Locker otherwise require. Customer is solely responsible for ensuring that the third-party scripts meet their security requirements. Salesforce is not responsible for, and has no obligation to provide support for recovery from any harm done to Customer’s solution by Customer, an ISV, or other party that places a script in trusted mode.
To turn on LWS trusted mode, first contact Salesforce Support. The LWS trusted mode permission must be enabled on each org where you intend to use it, including developer test orgs.
After Support turns on trusted mode, the Session Settings area of Setup presents additional user interface content for setting up trusted mode. This feature requires action by a Salesforce admin and a developer to use it.
Before you consider using trusted mode, be sure to read these topics.