Home Page › Forums › Office 365 › SharePoint › SPFX – External libraries?
Tagged: jQuery, SharePoint, SharePoint Framework, SPFX
This topic contains 4 replies, has 3 voices, and was last updated by Mark Stokes 2 weeks, 6 days ago.
Has anyone managed to get external libraries working with dependencies on another library. For example jQuery and Cycle2?
I’ve seen a few methods and workarounds and just wondered what methods people are using….
There is a lot of sample code on GitHub (https://github.com/SharePoint/sp-dev-fx-webparts). For example for jQuery, see: https://github.com/SharePoint/sp-dev-fx-webparts/tree/master/samples/jquery-photopile
Or look at Waldek’s https://github.com/SharePoint/sp-dev-fx-webparts/blob/master/samples/jquery-cdn/ which uses CDN.
In essence you need to add a dependency to the library using
npm install --save awesomelibrary
and then add an import in your MyWebpart.ts.
Thanks Bill, I hadn’t seen the Photo Pile example. It’s a good example with lots of dependencies on jQuery.
I think I have narrowed my specific problems down to jQuery Cycle 2. Doesn’t seem to work when referenced as an external file from CDN…
A few libraries seem to take a dependency on jQuery 1.9 and stop there. I think there were some big changes with jQuery when they went to version 2.
I have rolled many projects back from 2.x to 1.9x especially if you need horrible old IE support.
You must be logged in to reply to this topic.