SPFx - including external libraries like jquery

Iron Contributor

Hopefully this might save people some of the time I wasted trying to get a clear guidance on what to do for this. There are lots of old posts around that relate to earlier times.

This helpful Ignite session makes it really clear what to use when and how

https://myignite.microsoft.com/sessions/53866

 

The bit to notice is that modules and non-modules are treated differently.

Rencore have done a free script check to help you get the right code https://rencore.com/sharepoint-framework/script-check/

 

loading externals which are modules.PNGloading externals which are non-modules.PNG

This is a summary of what the video outlines for jquery and an extension script

jquery and extn declaredjquery and extn declared

 

import jquery dollarPNG.PNG

 

 

 

 

 

 

import the jquery and assign to dollar because the extension script will assume that symbol

require the extension

 

the you can reference the extension as normal

import jquery dollar ref.PNG

 

he does talk about "typings" in the video but my Typescript isn't good enough to grasp what this would look like and he doesn't explain. Maybe a Typescript guru can elaborate?

 

 

0 Replies