1

This question already has an answer here:

I was wondering how third party libraries with LockerService enabled can work in the near feature. I work in a project where we use jQuery, AngularJs etc... and I'm afraid that we have to rewrite all the code that I have in my orgs, specifically for that code that manipulate DOM. Is there some risk in that sense? Thanks in advance.

marked as duplicate by Mohith Shrivastava, martin, crmprogdev, sfdcfox, Santanu Boral Mar 24 '17 at 16:21

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2

LockerService has a (non-exhaustive) list of supported libraries on this post:

Library Version
React   0.14.8
ChartJS 2.1.4
D3  4.4.0
Leaflet 0.7.7 and 1.0.2
RxJS    Latest as of 12/5/16
Numeral.js  2.1.4
Underscore.js   1.8.3
FullCalendar    3.1.0
Gauge.js    1.2.1
jQuery  2.2.2 and 2.2.4
jQuery UI   1.11.4
DataTables  1.10.12
Select2 4.0.3

Other libraries may work, but have not been tested. There will likely always be supported as long as they are secure. Insecure libraries won't work.

Salesforce wants us to be able to use third-party libraries so we don't have to do total rewrites, but they also want data to be secure, so libraries that behave properly will work just fine, and libraries that do not won't be allowed to do things it should not, such as manipulating the DOM outside of the component it is contained in.

  • Thanks @sfdcfox! Vote my question if you think that could be useful for other users. – DarkSkull Mar 24 '17 at 14:18
1

Third party libraries should be uploaded as static resources in order to be used in your lightning apps/components once locker service is enabled/enforced in your org.

https://developer.salesforce.com/blogs/developer-relations/2016/04/introducing-lockerservice-lightning-components.html

Afterwards, you should reference them using the tag:

<ltng:require styles="{!$Resource.Namespace__Script1 + '/css/someCss.css'}"
 scripts="{!join(',',
          $Resource.Namespace__Script2+ '/js/SomeJs.min.js',
        $Resource.Namespace__Script3+ '/js/MoreJs.Dependencies.js'"/>

further information can be found here on using third party libraries. Locker Service enforces Content Security Policy standards, if you would like to read further on how Salesforce uses CSP, you can read here

Not the answer you're looking for? Browse other questions tagged or ask your own question.