Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Moving core.js loading into separate method #981
It is bad idea to merge core.js and motools loading.
Im working at my plugin, wich re-registers such methods as behavior.keepalive, behavior.formvalidation etc,
I don't like jQuery, MooTools is more beauty for me, BUT I'm using extensions, wich works on jQuery, and I'm forcet to use this js library and refuse from MooTools die to site weight optimisation.
This plugin works great in joomla 1.7, but in joomla 2.5 I cannot get rid of mootools due to core.js and framework merging.
Please separete this methods, I thing it is a good idea.
Ok, so I offer to call JHtml::_('behavior.core') from framework() method.
But, JHtml::core usage must be replaced with JHtml::('behavior.core'), not with JHtml::('behavior.framework') ( to prevent mootools loading when we only need to core.js.
So, core.js will be loaded in any way, wether we call JHtml::('behavior.core'), JHtml::('behavior.framework') or JHtml::script()
But if extension needs only core.js, it calls JHtml::('behavior.core'), if needs mootools , it calls JHtml::('behavior.framework')
Is it possible to make these changes ?
First of all I'd be very interested in your jQuery plug-in. Do you host it somewhere?
Now back to topic.
The code in core.js has depended on MooTools at least since Joomla 1.6, also at least since 1.6 JHtmlBehavior::framework() has loaded core.js, this used to be done by calling JHtml::core(). I just simplified the code since calling either one used to load both files.
I don't quite get what your concern is? That some extension the uses parts of core.js will call JHtml::_('behavior.framework')? How is it going to help you if we accept this pull request, JHtmlBeavhior::core() would still include MooTools.
I'm not saying I'm opposed to it, I'd just like to understand the problem first.
Ok, I have learned this problem deeper. I think it is possible to change a little bit of code without any combatibiltity problem, and with satisfaction of my interests.
First, what I think about usage of core.js and mootools framework:
Second, to avoid recursion in calls of framework and core each other (framework calls core, and core calls framework and so on) we need to break this dependence. Because of we cannot remove the call of core in framework method (due to b.comp.) we need to rewrite core.js in pure js. Its very easy, there are two only methods which uses mootools, and I have rewritten it (with help of js master) already.
In future, when we get rid of the core.js call from behavior.framework, we will be able to use mootools in core.js (because of there will not be double-dependence of methods)
Finally, what we get:
But, I don't how did you replace JHtml::core in CMS. I guess JHtml::('behavior.framework') ? But frontend parts of com_content, com_contact etc havent need to mootools, they dont use $, addEvent etc, only they need is core.js and other behaviors (tooltip, keepalive and so on)
I will place my plugin here. on github, but i havent yet have deal with it, so it takes a time :)
So, what do you think about it?
All changes i offered will not affect outside Htmlbehavior file
Haven't completely thought this trough but two three that came to my mind reading trough it:
We should probably deprecate that JHtmlBehavior::framework() loads the core.js file. That will mean we'll have to add quite a bit of code but I really don't wanna be stuck in no framework mode in core.js.
I'm glad to see you agree with some of my thoughts :)
You asked: 'Can you really override JHtmlBehavior partly?'
I'm not against using MooTools code in core.js, but we cant use it, until we remove core.js loading in framework method.
If we will call core.js in framework method, and will call framework in core method, we will get recursion.
So we have to remove core.js loading in framework method, or we have to remove framework call in core method.
Due to backward compatibilty we are not allowed to do first thing, so lets do second one.
After removing core.js loading in framework method, we will get availability to use MT in core.js again.
So, I must get back self:framework() lines in my patch, do I ?
@danyaPostfactum This is no longer mergeable. Can you rebase this so we can take another look? @realityking would you have another look at this and talk it through with the CMS folks as well so we can make a call?
I'm going to close this for now. @danyaPostfactum once you have rebased this so that it will cleanly merge again please re-open it so we can finish the discussion. My apologies for the delay in getting a decision made on it.