question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removing jQuery dependency -- A safe/sane approach

See original GitHub issue

We 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:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:27 (23 by maintainers)

github_iconTop GitHub Comments

4reactions
swederikcommented, Dec 8, 2017

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!

4reactions
swederikcommented, Nov 17, 2017

Just released Cornerstone Tools 1.1.0 which should finish Step 1.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing jQuery from GitHub.com frontend
We have recently completed a milestone where we were able to drop jQuery as a dependency of the frontend code for GitHub.com. This...
Read more >
Removing jQuery from GOV.UK - CSS-Tricks
Instead of upgrading disparate outdated versions of code and having to address security updates in a piecemeal approach, removing the dependency ...
Read more >
How We Removed jQuery from a large app - Chip Cullen
1. Remove the libraries that relied on jQuery · 2. Have a standardized replacement for some of the trickier methods · 3. Replacing...
Read more >
How to remove the dependency on jquery - Stack Overflow
It meets my requirement, but it requires jquery js, I would like to remove the dependence of jquery js file. I tried to...
Read more >
The Road to Removing JQuery from Gov.uk - InfoQ
From a developer perspective removing jQuery has been a long but worthwhile process. Rewriting our code has taught us a lot about it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found