We are creating several components to be used on a Lightning Community using the Napili template. Some of our components will require jQuery.
Now I've noticed, that in this release (Winter'16) an older version (v1.5.2) of jQuery is loaded by default in the vanilla community without any configuration or custom code from
/sfsites/assets/Scripts/jquery/jquery.js
Now how to deal with that fact inside our components?
If we do nothing at the first glance it's fine, we go with the shipped version 1.5.2 which might be sufficient. But I'm not sure if it's a good idea to use it, since it might be changed or removed in the future an then break the components. Plus at least for debugging it looks like we need to wrap the components in Standalone Lightning Apps to see any error messages as shown here
What is the best way to debug Lightning Components (used in the Community Builder)?
Using ltng:require to load jQuery will work fine for Standalone Apps but then on the other hand will end up with jQuery loaded twice in the community.
What is the best strategy here?
Best Answer
using
noConflict()
to manage multiple jQuery versions. I have no idea if this is the recommended way but it works for me.Example fiddle using versions 1.11 and 1.52 and the plugin Chosen which only works with versions 1.4+
Regarding a dynamic load time, why not just check the version and then assign it, since you know what version you're giving it.
Source