[RFC|Merged] Inclusion of jQuery
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Inclusion of jQuery
+1, so many things are so much easier in jQuery - event listeners (blergh DOM2 in 3.0 ), AJAX, DOM manipulation
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: [RFC] Inclusion of jQuery
I'm wondering what exactly we would replace with jQuery that is currently in use that wouldn't or isn't already handled by some basic JavaScript. In some instances I don't know that there is a whole lot of benefit vs. the added overhead of jQuery (or any other js library). I suppose the biggest one would be the color switcher and possibly the Smiley insertion. Some of the other stuff is so simple I'm not sure replacing EVERYTHING with jQuery would be worth it or would be more efficient. Showing/hiding panels also comes to mind especially in the ACP.
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Inclusion of jQuery
The code I was working on yesterday was the BBCode buttons on the signature edit page in the ACP. On *every single button*, it had an onmouseover= and onmouseout= (which is bad). The entire thing could have been shortened to:
That code probably doesn't work (Im writing this post from my phone), and I can't remember the names of stuff anyway, but you get the picture.
The reason that jQuery should be used for this is because Internet Explorer sucks, and it also makes attaching events to multiple elements really really easy.
EDIT: Here 'tis: https://github.com/phpbb/phpbb3/blob/09 ... e.html#L50
Code: Select all
var buttons = $('.button2');
buttons.bind('mouseover', function()
{
helpline(this.accesskey);
});
//helpline should default to tip, too.
buttons.bind('mouseout', helpline);
The reason that jQuery should be used for this is because Internet Explorer sucks, and it also makes attaching events to multiple elements really really easy.
EDIT: Here 'tis: https://github.com/phpbb/phpbb3/blob/09 ... e.html#L50
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Inclusion of jQuery
A couple more notes from me:
In my opinion, phpBB should be using the google CDN with a local fallback. It's very easy to do (see HTML5BL) - two lines of code. The only time I remember the Google CDN going down was a while ago, and a large chunk of the Internet broke for a few hours. Using the latest jQuery file on the CDN (jquery.js, not jquery-1.x.x.js) would be less secure in the case of vulnerabilities or bugs being found in jQuery, but it would remove the need for patch releases if a buggy version of jQuery was released with phpBB.
I also think that the core phpBB js should be changed to jQuery for 3.1, not 3.2 as suggested above. With the right tools, it is extremely fast to write, it's just a matter of finding it (which only I would find difficult).
In my opinion, phpBB should be using the google CDN with a local fallback. It's very easy to do (see HTML5BL) - two lines of code. The only time I remember the Google CDN going down was a while ago, and a large chunk of the Internet broke for a few hours. Using the latest jQuery file on the CDN (jquery.js, not jquery-1.x.x.js) would be less secure in the case of vulnerabilities or bugs being found in jQuery, but it would remove the need for patch releases if a buggy version of jQuery was released with phpBB.
I also think that the core phpBB js should be changed to jQuery for 3.1, not 3.2 as suggested above. With the right tools, it is extremely fast to write, it's just a matter of finding it (which only I would find difficult).
Re: [RFC] Inclusion of jQuery
As was mentioned in another topic the jquery include should be moved from head into the footer.
So basically we offer no guarantees of js compatibility in patch releases?igorw wrote: Ok, judging from the wikipedia release history there is only one development line. So when 1.7 is released, there are likely no more updates to 1.6. For this reason I think we should always ship the latest version available whenever we release a new version of phpBB.
- nickvergessen
- Former Team Member
- Posts: 733
- Joined: Sun Oct 07, 2007 11:54 am
- Location: Stuttgart, Germany
- Contact:
Re: [RFC] Inclusion of jQuery
Well, we had one patch release so far and I hope we dont ever get another one. And I'd say yes, we may ship it with an outdated jQuery in that case.Oleg wrote:So basically we offer no guarantees of js compatibility in patch releases?
Member of the Development-Team — No Support via PM
- DavidIQ
- Customisations Team Leader
- Posts: 1904
- Joined: Thu Mar 02, 2006 4:29 pm
- Location: Earth
- Contact:
Re: [RFC] Inclusion of jQuery
This explains what was mentioned in another topic by callum. But what's the purpose/benefit behind this?Oleg wrote:As was mentioned in another topic the jquery include should be moved from head into the footer.
Re: [RFC] Inclusion of jQuery
To speed up initial rendering of the page. It does not need to wait for jquery to load before rendering the page that way. The javascript is loaded at the end and then attaches event handlers to various elements.
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Inclusion of jQuery
To add to what naderman said:DavidIQ wrote:This explains what was mentioned in another topic by callum. But what's the purpose/benefit behind this?Oleg wrote:As was mentioned in another topic the jquery include should be moved from head into the footer.
The rendering engine loads the page in the order it reads it (duh). When it gets to something like a reference to a style sheet or external script (but not images), it stops doing everything else and loads the external stuff instead, before resuming page load. Putting it in the page footer won't actually speed up page loading time, but it will appear to, as it will refer the body before downloading and rendering the large jQuery library. Therefore, on sites that do not rely on jQuery / JS on page load, JavaScript should be put in the footer.
Nothing will use or rely on jQuery at page load.
~Callum
Re: [RFC] Inclusion of jQuery
I have moved jQuery to the bottom of the page. This however means that we cannot use jQuery in any in-line javascript and that we have to stick all of our JavaScript into one huge file.
That trade-off works for me, it forces us to take a clean approach to our JavaScript and properly rewrite any of the existing code. We might want to consider some kind of compilation/concatenation though, because sticking everything in one file is kind of cumbersome in development.
Thoughts?
That trade-off works for me, it forces us to take a clean approach to our JavaScript and properly rewrite any of the existing code. We might want to consider some kind of compilation/concatenation though, because sticking everything in one file is kind of cumbersome in development.
Thoughts?