We are developing some web applications using Silverstripe and want to use a recent version of jQuery.
Sapphire, the framework that Silverstripe runs on requires their (older) version of jQuery using the following code:
Requirements(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js');
This includes a link to this file on all generated web pages. We can block this requirement using the following code outside of the framework in the Page_Controller class:
Requirements::block(SAPPHIRE_DIR .'/thirdparty/jquery/jquery.js');
This removes the include from all generated web pages but it also removes the include from the Silverstripe CMS – causing it to break.
The (almost) simple fix for this is for us to copy our version of jQuery into /sapphire/thirdparty/jquery/jquery.js – but we are trying to keep the Sapphire framework untouched and clean for future upgrades.
This also creates problems as using the native Silverstripe requirements means that jQuery almost loads last on the page – breaking some of our functionality.
Is there anyway to block the loading of Silverstripe’s jQuery on the websites but allow it in the CMS?
SilverStripe is including jQuery in your pages because you either have
$SilverStripeNavigatorin your.ssfile or a module you are using is requiring it. Additionally, addingRequirements::block();to thePage_Controllershould not effect the CMS.