Removing jQuery dependency -- A safe/sane approach
See original GitHub issueWe depend on jQuery for…
- Promises
- DOM selection (mostly in examples)
- Triggering custom events
- Listening for custom events
- HTTP calls?
All of these can be replaced with vanilla JS equivalents (with a dash of polyfill) to:
- Maintain IE 10+ support
- Reduce overall filesize
- Eliminate a “global” dependency
- Leverage “single purpose” libraries
I think the easiest way to transition is as follows:
1. Add duplicate custom event triggers in Cornerstone
using vanilla js
- Current Support
- Polyfill for older browsers
Cornerstone
and CornerstoneTools
will continue to work using the jQuery
events, but this allows us to migrate existing tools in chunks, and to create new tools that rely on custom event
without worrying about breaking existing functionality.
2. Migrate tools and examples as we build out [the new documentation](https://dannyrb.gitbooks.io/cornerstone-tools/) to use vanilla DOM selection and the new custom events
.
The tight coupling between Cornerstone
and CornerstoneTools
and what we use for events has likely been the biggest deterrent in dropping jQuery. The rest of the work is much easier, and satisfied with “up for grabs” issues.
3. Clean up any remaining jQuery event based logic in either library.
Now we no longer need to worry about the implications changes either library will have on the other. We can finish our jQuery cleanup in each as a separate initiative.
4. At our leisure, replace any jQuery HTTP requests with axios equivalents.
5. Replace jQuery promises with bluebird - Support
Throw a 🌲 on the 🔥 Bust open some 🍾 Because it’s time to 🎉 🎈
Goodbye jQuery
@swederik, curious to hear your thoughts. I think this can be broken down into a series of smaller issues, and then we can track the progress of this larger goal using GitHub milestones/projects?
Would love any feedback/suggestions you may have before I take a stab at item number 1 for this repository.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:27 (23 by maintainers)
Top GitHub Comments
Finally released Cornerstone Core, WADO Image Loader, and Web Image Loader major versions without jQuery!
Thanks to all that have helped! Please test and report any issues with these libraries. Only Tools is left, so I would appreciate any PRs to help make Cornerstone jQuery-free!
Just released Cornerstone Tools 1.1.0 which should finish Step 1.