Skip to main content
Home  ›  Blog

bye jQuery - go fetch(...) - 2sxc 12.10

2sxc 12.10 is finally free from jQuery. Here's what you need to know...

Free from jQuery

jQuery has been a really amazing helper tool for more than 15 years. But as browsers have matured, it's become an unnecessary burden. 

jQuery was loved for things like:

  • fixing browser incompatibilities (this is no real issue any more)
  • implementing promises (modern browsers have this built in)
  • having a quick ajax-call which was much simpler than creating an XHR request (fetch took care of this)
  • simple animations (CSS can do most of this)
  • running code when ready (turnOn is better at this)

All this isn't necessary any more, but so many system rely on jQuery, that it's become a kind of a virus, hard to get rid of. Dnn has been bundling jQuery since forever, and Bootstrap 3 and 4 have used jQuery as an integral part. 

This is bad for various reasons, including that the PageSpeed score is reduced when your page waits for jQuery to do it's magic. 

But not any more: Bootstrap 5 is now completely without jQuery and most JS plugins like Fancybox have moved on.

We used to be proud to be using jQuery, but today every plugin is proud to be plain-vanilla JS. 

Finally we did it

The jQuery-virus had also been part of 2sxc for many years, permeating both edit-ui-code, the $2sxc and the inpage editing experience. But as of 2sxc 12.10, we are now completely jQuery free. 


#1 Nope, Your jQuery based JS won't Fail

If you are using jQuery in your apps, they will continue to work. It's just that 2sxc doesn't need it any more, so if you create clean solutions, you can disable jQuery completely. 

#2 Yes, You Can still use jQuery if You Want to

If your skin or templates still import jQuery - either with a script-tag or using the iPageService Activate("jQuery") then jQuery is still there and you can use it for whatever you want. 

#3 Existing code using sxc.webApi.get(...) still returns a jQuery Promise

The 2sxc JS API had commands like webApi.get(...) and which returns a jQuery promise. This will continue to work, if you have jQuery enabled on the page. For compatibility reasons, we left the signature as is, but these get/post/put/delete commands are now deprecated, but will continue to work indefinitely. 

If you can, please migrate to fetch (see below). 

How to Replace jQuery in Your Code

#1 Use fetch instead of $.ajax

All modern browsers support fetch and we strongly suggest you go that way as well. It's just as easy to use as $.ajax and the sxc-controller also has a new webApi.fetch(...) and webApi.fetchJson(...) as well. This also return a modern standard promise instead of the jQuery promise which is deprecated. 

👉 To get started, check out our updated WebAPI tutorials

#2 Use turnOn instead of $(...).ready

One of the most common things jQuery was used for is to run your code when the document is ready. But this resulted in some complex spaghetti-code, because even if the document was ready, some of the plugins may not have been initialized yet. 

Because of this, 2sxc includes turnOn which does a much better job starting your code in all kinds of scenarios. 

#3 Use Standard Promises

The jQuery promise was a great idea but the standards have implemented them slightly differently. You should really move on. Read about standard Promises in the MDN docs

#4 Use Css Animations

Most jQuery animations were fairly simple, and modern CSS can do that as well, just faster and more efficiently. 

Get it now

Get the latest 2sxc 12.10 or newer from the github releases

Love from Switzerland and Croatia,

Daniel Mettler grew up in the jungles of Indonesia and is founder and CEO of 2sic internet solutions in Switzerland and Liechtenstein, an 20-head web specialist with over 800 DNN projects since 1999. He is also chief architect of 2sxc (see github), an open source module for creating attractive content and DNN Apps.

Read more posts by Daniel Mettler