[RFC|Merged] Include and use jQuery (originally for 3.2)

These requests for comments/change have lead to an implemented feature that has been successfully merged into the 3.1/Ascraeus branch. Everything listed in this forum will be available in phpBB 3.1.
Post Reply
igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

[RFC|Merged] Include and use jQuery (originally for 3.2)

Post by igorw »

RFC for 3.1

What is jQuery?

(skip this if you already know)

jQuery is a JavaScript library that greatly simplifies DOM scripting by providing CSS selectors to access DOM elements. For example:

Code: Select all

$('div.login-form input[type=submit]').click(function() {
    $(this).hide();
});
For more information check out the jQuery docs.

Proposal

It would be very useful to have jQuery included in the phpBB 3.x core. Other libraries can be considered, however jQuery is likely the most popular.

What's in it for phpBB

In many places it may be possible to rewrite existing JS code to use jQuery, simplifying it to a great extent. This makes the code a lot more maintainable.

What's in it for MODs

There is at least one MOD that uses jQuery. If several MODs do this they create a conflict. By making jQuery available directly, such issues are avoided. Because it makes almost any DOM development a lot easier, it's use should be strongly encouraged for any MODs that touch JavaScript.

Keep in mind
  • Performance
    jQuery does add additional load to the page in different ways. Also, while jQuery is really convenient, there are things that need to be done to make it perform, such as caching matched elements. Some information here.
  • Distribution/Packaging
    When adding third party libraries to phpBB, these need to be maintained. Each minor release should update jQuery to the latest version. Security issues in jQuery should result in a PL (patch level) release.
  • Alternatives
    Are there any alternative libraries that can be considered? Dojo, prototype, others?

User avatar
Erik Frèrejean
Registered User
Posts: 207
Joined: Thu Oct 25, 2007 2:25 pm
Location: surfnet
Contact:

Re: [RFC] Include and use jQuery

Post by Erik Frèrejean »

Yay please :). I've noticed when looking at my own MODs that I include a lot of javascript lately to perform small tasks, just for the ease of things I use jQuery for this. The main disadvantage is that all your MODs will include instructions to install jQuery to the templates. Which as you state can conflict.
IMHO the biggest gain is that it is certain that the latest version of jQuery is shipped and that security problems within the library are patches as well, this way if a user has a MOD installed that uses jQuery he doesn't have to update manually or wait for the MOD author to update the MOD.
Available on .com
Support Toolkit developer

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Include and use jQuery

Post by EXreaction »

Why not include it in 3.1? Or even in 3.0.8?

Even if we do not use it in either it will be usable for modifications and such.

Also, we could use the google hosted version of jquery and link to the latest version to not worry about security patches.

Nelsaidi
Registered User
Posts: 122
Joined: Tue Nov 11, 2008 5:44 pm

Re: [RFC] Include and use jQuery

Post by Nelsaidi »

EXreaction wrote:Why not include it in 3.1? Or even in 3.0.8?

Even if we do not use it in either it will be usable for modifications and such.

Also, we could use the google hosted version of jquery and link to the latest version to not worry about security patches.
With the google hosted version, a fallback to a local installation would be required imo - or just use the latter.

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] Include and use jQuery

Post by DavidIQ »

EXreaction wrote:Also, we could use the google hosted version of jquery and link to the latest version to not worry about security patches.
If there are security patches it would likely be released through a new version. So http://ajax.googleapis.com/ajax/libs/jq ... ery.min.js would not have the patch anyways unless they have some different way of handling security patches like applying them to existing versions and leaving the version number alone...
Image

User avatar
DavidIQ
Customisations Team Leader
Customisations Team Leader
Posts: 1904
Joined: Thu Mar 02, 2006 4:29 pm
Location: Earth
Contact:

Re: [RFC] Include and use jQuery

Post by DavidIQ »

I take that back. There is a CDN entry that is not version dependent (http://ajax.googleapis.com/ajax/libs/jq ... ery.min.js) it's just not listed in the jQuery site. However I think this could be included in 3.1 with a switch for MODs and all javascript in phpBB switched to using jQuery by 3.2.
Image

topdown
Registered User
Posts: 12
Joined: Sat Dec 01, 2007 5:04 am

Re: [RFC] Include and use jQuery

Post by topdown »

If this is not going to be in the style itself then there needs a way to over write it from the style, so that say, if your version is not what I want I can over ride it and phpBB's is not loaded.
Keep that in mind please. ;)

User avatar
Raimon
Former Team Member
Posts: 67
Joined: Sun Mar 19, 2006 1:21 pm
Contact:

Re: [RFC] Include and use jQuery

Post by Raimon »

Nelsaidi wrote:With the google hosted version, a fallback to a local installation would be required imo - or just use the latter.
+1 Please do that, i really not like to use the Google version, sure it is up to date, but what if Google is down? a lot of boards will not work then (and yes this CAN happen) and we should prevent such things so board users would not have any issues with it when it happens.
Or if we include it in the style, perhaps a check if we use the latest release would be also nice, if not show them the update link so the can update it by them self, but phpBB 3.x should also include the latest version.

User avatar
EXreaction
Registered User
Posts: 1555
Joined: Sat Sep 10, 2005 2:15 am

Re: [RFC] Include and use jQuery

Post by EXreaction »

I would bet that google is as reliable as the user's own webserver in relaying the file. :P

The two biggest parts are:
Using google we can make sure jquery is always up-to-date by using the latest
Google will probably handle browser caching better than the user's webserver

igorw
Registered User
Posts: 500
Joined: Thu Jan 04, 2007 11:47 pm

Re: [RFC] Include and use jQuery

Post by igorw »

3.1 might be an option, but I don't really see it for 3.0.8. It depends on the demand from MOD authors, especially if we aren't porting the current JS. If certain new features could use it, I'd be all for including it, but it's a bit late for that to happen with 3.1.

Including jQuery will add overhead in terms of requests and client side performance, which is significant.

Including JavaScript from a third party server is not really acceptable. There are several issues, you have the trust and security problem. What if google decides to do something evil? There is currently no easy way to verify the hosted version of jQuery was not modified. Then you have availability, what if google goes down?

Sure, you do get some benefits from using a public CDN, but there are issues with it that cannot be ignored.

Post Reply