Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate Dependency on jQuery - Tasklist #3981

Closed
2 tasks
avalanche1 opened this issue May 1, 2016 · 16 comments
Closed
2 tasks

Eliminate Dependency on jQuery - Tasklist #3981

avalanche1 opened this issue May 1, 2016 · 16 comments
Labels

Comments

@avalanche1
Copy link
Member

avalanche1 commented May 1, 2016

  • Create a list of all jquery functions SUI uses on the left and their modern alternatives on the right.
  • next task
@controversial
Copy link

controversial commented May 1, 2016

Looks good. We can probably start with http://youmightnotneedjquery.com.

@avalanche1 How familiar are you with this codebase? Is jQuery mostly used for animations, or is it used for all kinds of DOM manipulation, etc?

@avalanche1
Copy link
Member Author

avalanche1 commented May 1, 2016

I'm only a user of a few modules, not an active contributor. Jack is the expert here.
Skimming through https://github.com/Semantic-Org/Semantic-UI/blob/master/dist/semantic.js I come to realize that it isn't a trivial task. We need some type of automation here.
Maybe a reference of all jquery API and check against semantic.js - which ones are present

@henri-hulski
Copy link

It could be worth looking what @hallister and @asvetliakov have done for eliminating the jQuery dependency in semantic-react.
There is also an interesting discussion about replacing jQuery with React based modules at jessy1092/react-semantify#20.

@hrstoyanov
Copy link

I was talking to @jlukic before about dropping jQuery from SUI ... it is basically not going to happen. The JS module code is heavily dependent on jQuery. I learnt to live with it.

@Ryuno-Ki
Copy link

Ryuno-Ki commented May 7, 2016

What about migrating to jqLite first?

This way, the first step would be to replace DOM accessors. Angular users would benefit from it I guess.

@Assassyn
Copy link

Assassyn commented May 13, 2016

Problem with migrating to jqLite is that it is possible to hit the problem of missing implementation.

It migth not be the easies but moving to vanila js or maybe TypeScript (my preference) seems like a proper way.

Looking at the code is all modules, splited into separet files, so taking module by moduels should be achivable. It might require to leave the jQuery wrapping until all work is done.

Edited:
changed TS to typescript.

@levithomason
Copy link
Member

Adding our React implementation to this list, Stardust :) My previous comment on a related thread:

At TechnologyAdvice we are using https://github.com/TechnologyAdvice/stardust in production. We have 6 humans and 2 robots working on it so far. I spend the majority of my day job on Stardust.

I am rewriting the modules without jQuery. We first tried to keep SUI DOM manipulations in sync with React state through each of the library's lifecycle methods, in the end, this just was not realistic.

I've rewritten the Dropdown with selection, search, and complete keyboard navigation. You can try it out here. I will continue to move forward with all other modules as well. If any one is interested in assisting, let me know.

@Assassyn
Copy link

@avalanche1: I mean typescript, I have edited my previus post.

@levithomason: it is great, but what is a point of moving from jQuery to React? People which are using any other framework than React might have problems. I think that possible solution is to add a thin layer to allow the use of differenet frameworks, similair solution to angular ones.

@levithomason
Copy link
Member

My comment was in regard to #3981 (comment)

It could be worth looking what @hallister and @asvetliakov have done for eliminating the jQuery dependency in semantic-react.
There is also an interesting discussion about replacing jQuery with React based modules at jessy1092/react-semantify#20.

For those looking for a React implementation of SUI. Since no matter the choice of JS SUI uses for DOM manipulation, it will always be incompatible with React's virtual DOM.

@asvetliakov
Copy link

@levithomason Glad you're going fine with stardust 😃

@italomaia
Copy link

Moving to "react" would be kind of bad for a lot of people.
@Assassyn one could also use Flow instead of TS, which is less intrusive.

@levithomason
Copy link
Member

To clarify, the React components are not intended to help non-react apps. They are required for React apps as vanilla JS and jQuery DOM manipulations do not work in React.

@13protons
Copy link

13protons commented Apr 13, 2017

Maybe something tiny like https://umbrellajs.com/ (I'm not affiliated) could handle this. Umbrella is mostly jQuery compatible, and would not also bring on the pain of recreating everything jQuery had been doing.

@franciscop - any interest?

@franciscop
Copy link

franciscop commented Apr 14, 2017

@alanguir thanks for proposing my library and yes, I'd be really interested. Though I have to ask first, what is the reason to remove jQuery? And is jQuery available for people using the library or just used internally?

Umbrella's codebase is really modular though many modules are tightly coupled (to optimize for size) so you could just remove some parts if they are not needed. It stands at 3kb min+gzip right now. Some functions might also be missing so if it makes sense I'd be willing to implement them inside umbrella or as a separate file.

PS, great work with Semantic UI, I have known it for a while and I love it

@italomaia
Copy link

italomaia commented Sep 27, 2017

As chamadas ao jquery no semantic são estas:

  1. $.Deferred,
  2. $._data, (not really jquery)
  3. $.address, (not really jquery)
  4. $.ajax,
  5. $.api, (not really jquery)
  6. $.contains,
  7. $.cookie,
  8. $.data,
  9. $.each,
  10. $.easing,
  11. $.events,
  12. $.expr,
  13. $.extend,
  14. $.grep,
  15. $.inArray,
  16. $.isArray,
  17. $.isEmptyObject,
  18. $.isFunction,
  19. $.isPlainObject,
  20. $.isWindow,
  21. $.merge,
  22. $.removeCookie,
  23. $.site, (not really jquery)
  24. $.tab, (not really jquery)
  25. $.test, (not really jquery)
  26. $.trim,
  27. $.visit, (not really jquery)
  28. $.when

It also uses $.fn a lot.

I used this script to build the list:

import io, re, os
rs = set()
c = re.compile(r"\$\.\w+") 

for root, dirs, files in os.walk("."):
    for file in files:
        if file.endswith('.js'):
            path = os.path.join(root, file)
            with io.open(path, 'r', encoding='utf-8') as fs:
                data = fs.read()
                for m in c.findall(data):
                    rs.add(m)

Semantic-ui clearly uses very few jquery functions. Maybe lodash + axios + "some events library"? could supply all that semantic-ui needs with just enough fat to the side.

@stale
Copy link

stale bot commented Feb 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Feb 23, 2018
@stale stale bot closed this as completed Mar 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests