[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
User avatar
hanakin
Front-End Dev Team Lead
Front-End Dev Team Lead
Posts: 968
Joined: Sat Dec 25, 2010 9:02 pm
Contact:

Re: [RFC] Include and use jQuery

Post by hanakin »

I am all for including jquery. I have used a couple different js frameworks in the past such as mootools, dojo, & scriptaculous; however JQuery for me far out weighed them. Weather it be in easy of use, familiarity, documentation, speed, and file size.

I would say the best way to implement it would be to include it from googles CDN with the option to use a local version, this is useful not only for those who do not have access to the CDN but for those of use who operate a forum internally on an intranet or an offline test server.

You could do it the other way around however for the sheer fact that it would require less updates in this manner.

As for the numerous rants at the security/reliability of a CDN, I have been using the cdn for several years on several clients sites and have never come across a single issue with it going down or any other sort of issues.

Those who have pls post some details and examples I am sure this would hep the developers to make their decision
Donations welcome via Paypal Image

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Include and use jQuery

Post by Oleg »

I read http://jqueryvsmootools.com/ and based on that was going to vote for jquery. But then I read http://thinkrelevance.com/blog/2009/01/ ... query.html and started having doubts. Myself I have a lot of experience with prototype and less with other frameworks.

Then I checked google trends: http://www.google.com/trends?q=jquery%2 ... ui%2C+dojo

If jquery is anywhere as popular as it appears to be from that graph, and especially if it is already used by a vast majority (?) of modifications then we should probably go with it even if it has listed deficiencies.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: [RFC] Include and use jQuery

Post by MattF »

Ultimately, in my dream, jQuery or motools or prototype - none of them would be a choice, because they'd all be available and included in phpBB.

In my dream, the ACP would have an option to turn on any of these libraries, which would then automatically include them in the overall header. You could also have the choice to have them come from your local server or a hosted CDN like Google.

The MOD coding guidelines would allow MOD authors to write MODs that can take advantage of any of these libraries, but they must follow some guidelines, like their MOD must use no-conflict coding (like use jQuery() instead of $()), their MOD can not provide the library but must make use of whatever version of library is included with the most current version of phpBB, and their MOD's installer file will turn on the correct library's ACP setting (if it isn't already on).
Has an irascible disposition.

User avatar
Marc
Development Team Leader
Development Team Leader
Posts: 195
Joined: Thu Sep 09, 2010 11:36 am
Location: Munich, Germany

Re: [RFC] Include and use jQuery

Post by Marc »

The current size of the libraries:

jQuery: 83,9 kB
MooTools: 86,4 kB
Prototype: 159 kB

You could include the files with phpBB but we should make sure they are not loaded on every page as that would increase traffic more than it's needed.

329,3 kB is more than a standard prosilver needs. If you add this to the page some people will have very long loading times.

This could be done by an include in the HTML file, i.e.:

Code: Select all

<!-- INCLUDE js_jquery -->
With this you could also prevent duplicate inclusion.

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC] Include and use jQuery

Post by Oleg »

The idea here is that we will use whichever javascript library we choose to bundle in the core.

Because these libraries mostly cover the same functionality I see no reason to bundle more than one library - modifications should use whichever library the core ends up shipping, unless they integrate some package that already uses a different library with phpbb.

Statistics on current library usage from cdb:

Code: Select all

pie@jungle cdb % find extract|grep jquery.\*js |wc -l
      51
pie@jungle cdb % find extract|grep prototype |wc -l  
       6
pie@jungle cdb % find extract|grep mootools |wc -l 
       5
Full stats: https://gist.github.com/939028

jquery is enjoying a strong lead. You can also see that different modifications include different versions, from 1.3 to 1.5 and some don't specify a version number at all. The jquery ui situation, that is, different mods needing different parts of the complete package, needs to be thought out as well.

One reason to use something other than jquery is that jquery's name is rather painful to type.

User avatar
MattF
Extension Customisations
Extension Customisations
Posts: 675
Joined: Mon Mar 08, 2010 9:18 am

Re: [RFC] Include and use jQuery

Post by MattF »

marc1706 wrote:The current size of the libraries:

jQuery: 83,9 kB
MooTools: 86,4 kB
Prototype: 159 kB

You could include the files with phpBB but we should make sure they are not loaded on every page as that would increase traffic more than it's needed.

329,3 kB is more than a standard prosilver needs. If you add this to the page some people will have very long loading times.

This could be done by an include in the HTML file, i.e.:

Code: Select all

<!-- INCLUDE js_jquery -->
With this you could also prevent duplicate inclusion.
But the browser should cache them after the first load, so the user would only feel it whenever it is loaded the first time.. But I'm all for just going with one-jQuery anyhow.
nn- wrote:One reason to use something other than jquery is that jquery's name is rather painful to type.
If you are going to go ONLY with jQuery, then you can use the $ instead of typing jQuery.
Has an irascible disposition.

User avatar
RMcGirr83
Registered User
Posts: 360
Joined: Fri Mar 09, 2007 1:51 am
Contact:

Re: [RFC] Include and use jQuery

Post by RMcGirr83 »

Just an FYI, while an excellent library certian elements of jQuery are known to not work correctly on all browsers, eg the "unload" function while it functions within FF and IE, it does not work on Chrome, Opera or Safari.
Do not hire Christian Bullock he won't finish the job and will keep your money

User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Include and use jQuery

Post by naderman »

Seems I haven't replied to this topic before. I'm for the inclusion of jquery simply because we need some standard js functionality and jquery is rather well known and should be familar to many developers. Since this seems like a relatively trivial change we can probably merge it into 3.1 as well (if done before the first beta release).

Oleg
Posts: 1150
Joined: Tue Feb 23, 2010 2:38 am
Contact:

Re: [RFC|Accepted] Include and use jQuery

Post by Oleg »

Marking accepted. I will leave this in 3.2 until there is some code implementing the RFC.
IRC wrote: (16:20:54) naderman: nn-: jquery +1
(16:21:00) naderman: and 3.1 too
(16:21:28) naderman: not sure if we should use a CDN or deliver it ourselves though
(16:22:11) naderman: I've been asking for jquery in 3.x since before 3.0 I think ^_^
(16:22:22) nn-: why jquery?
(16:22:47) naderman: does many of the things we need and is kind of a defacto standard
(16:23:04) naderman: simply the most widely spread, and thus best known one
(16:23:11) naderman: which means a lot of people will already be familar with it
(16:23:25) naderman: I don't particularly favour it over other frameworks for featureset/performance or anything
(16:24:18) marc1706: I wouldn't use a CDN especially since an update to jquery on the cdn could break pretty much all phpBB boards
(16:24:31) marc1706: or you could let admins choose
(16:24:48) igorw: I'm also against a CDN, at least as default setting
(16:24:59) marc1706: that's what I was just going to write :P
(16:25:15) naderman: yeah
(16:25:21) nn-: is this enough of a consensus? can we mark that accepted?
(16:25:24) naderman: I guess a setting might work
(16:25:28) naderman: nn-: yeah go ahead
(16:25:34) naderman: actually I'll quickly post my +1
(16:25:40) igorw: including jQuery is a good idea, but if we don't actually use it in core it seems kind of heavy to enable it
(16:25:48) naderman: nn-: consensus is consensus amongst participants
(16:26:00) naderman: ;-)
(16:26:02) nn-: igorw: we will use it. viewtopic.php?f=108&t=33747&start=30#p223365
(16:26:50) bantu: agree
(16:27:13) igorw: also while jQuery is probably not the best quality lib out there it is a de-facto standard, everybody knows how to use it and it's certainly extremely user friendly

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

Re: [RFC|Accepted] Include and use jQuery

Post by igorw »

Pull request: https://github.com/phpbb/phpbb3/pull/173

Needs testing and review.

Post Reply