-
Notifications
You must be signed in to change notification settings - Fork 185
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
Make jQuery optional #548
Comments
https://www.npmjs.com/package/xtend |
Please remove the requirement for jqeury. The only reason I am using the jquery plugin is for this editor. I actually want to strip jquery out of it myself but would require some time to study the code. I'm not a fan of plugins here plugins there.. People are ramming plugins into something that requires one line of code. I understand back when this was in its baby stages jquery was all the noise. Now the noise needs to be removed. Please do! |
@TwinFuture SCE uses jQuery quite extensively. There are still quite some bugs that jQuery seamlessly solves that SCE depends on. |
I don't have time now to update, make sure it is working and then try zepto but yeah, I was thinking a lib like that one. |
appear that Zepto not will increase performance |
I've been thinking about this and I think if this is going to be done it should be done as part of v2 as it would be slightly backwards incompatible. There are a few methods that currently return jQuery objects which would have to return plain DOM nodes. So I'm going to create a test branch to try it out and see if it's worth it or not. |
So far I've managed to remove jQuery from everything other than the plugins (0598d76). Size wise it's a little smaller when just uglified and about the same size when uglified and gzipped. I suspect removing jQuery from the plugins might increase the size a little bit but not much. So it looks like removing jQuery as a dependency is doable but it'll need a lot of manual testing. Switching to ES6 modules might help a little as it allows splitting the code up without increasing size which should make it easier to make the code more unit test friendly. Backwards incompatible changes
|
I've removed jQuerty from the BBCode and XHTML plugins in the remove-jquery branch to see how that affects things. The file sizes for SCEditor with the BBCode plugin are:
So file size wise removing jQuery shouldn't negatively affect jQuery users. Backwards incompatible changes
The BBCode format one is quite bad but should be able to create a backwards compatibility script to create the old behaviour. Something like: var bbcodes = $.sceditor.bbcode.bbcodes;
Object.keys(bbcodes).forEach(function (key) {
var oldFormat = bbcodes[key].format;
if (typeof oldFormat === 'function') {
bbcodes[key].format = function (element, content) {
oldFormat(jQuery(element), content);
};
}
}); I think this is worth doing despite the backward incompatibles as most of them can be fixed with a backwards compatibility script and it removes the jQuery dependency which is larger than the whole editor! If any one has any thoughts on this please add them. |
Now that IE < 9 has been dropped the jQuery requirement could also be made optional. SCEditor would still hook into jQuery if it's loaded as it does now but it would also allow using SCE without jQuery.
I've tried to make a complete list of the bits that are currently used by SCE:
Nearly all of which have native equivalents now meaning jQuery should be able to be replaced with a minimal wrapper. The main ones without a native equivalents are
$.extend
and the class manipulation methods (IE 9 doesn't support classList annoyingly) which isn't too bad.If any one has any thoughts about this either for or against please add them.
The text was updated successfully, but these errors were encountered: