Remove jquery from default.js

Hi.

I'm using plone 5.

How can I remove jquery from loading in default.js

Thanks.

Out of curiousity, why do you need to remove jquery?

Conflicts and overrides

plone is loading 1.11.3 and I need to use 3 or greater.

By server latency and over the wire stuff sometimes the script catch the 1.11 and others 3.5

Thanks.

I would explore using requirejs to override the default jquery. I don't know how to do that without some googling. Maybe someone else on this forum has more immediate recollection of how to do that. In the meantime this note may at least point you in the right direction.

I'm reading the docs about the resource registry but without success.

It says how to add but not how to remove.

I'm looking to other addons code registry.xml to see if I can find something, but again without success.

Thanks for the replies XD

Maybe look at this:

This may not fit everyone's use case, but due to its simplicity it may be worth a try.
On this page, the client wanted to include a 3rd party script that creates a form in an iframe. However, the script also does a check to make sure that a recent version of jQuery is in use. If it's too old, it slaps an error banner across the top of the page.

The solution was to merely paste this snippet right before the iframe script tag in the editable portion of the page:

<script src="https://code.jquery.com/jquery-3.4.0.min.js" integrity="sha256-BJeo0qm959uMBGb65z40ejJYGSgR7REI4+CW1fNKwOg="
crossorigin="anonymous"></script>

No futzing with the resource registry at all! Yes, you are loading at least two different versions of jQuery, but it works :smiley: to my surprise.

In this case, Disable HTML filtering was checked on @@filter-controlpanel, since the only editors on the site are trusted employees.
Also, I added text/x-web-markdown in @@markup-controlpanel, so they don't need to use TinyMCE for pages such as the one in question.

1 Like

Related: https://github.com/plone/plone.staticresources/issues/71

I just need to remove it.

Even calling to remove the whole bundle it won't remove the bundle

    def __call__(self):
    remove_bundle_on_request(self.request, 'plone')

I still get it the default.js with the jquery

Try:

def __call__(self):
    remove_bundle_on_request(self.request, 'plone-base')

Note: all other JavaScript won't work then...

Or - if you want to have jquery just removed or updated at all you can customize your bundle like described here: Image Captions from Plone 5.1

Apply the steps for the plone-base bundle.

If you want to use Plone's JavaScript functionality (probably, if you use the Plone default UI), I'd suggest to upgrade jQuery in the plone-base bundle and live with the fact that the drag/drop functionality won't work (resorting folder contents for example). Doing so I would not be surprised if JS still work at all if the drag/drop library throws an error.

The best options is @fulv's approach, if this works for you...

I hope we can upgrade jQuery soon...

Also check the bundling code in Products.CMFPlone maybe this has been changed, but I remember seeing require.js and jquery were always bundled and served, at least when you’re not running in production mode. But this could have been Plone 5.1 as well. @thet knows better. :slight_smile:

Stumbled on this note about deregistering require and define. It may be a clue for getting the version of jquery you want