Standardize Javascript Libraries for phpBB MODs

Discuss general development subjects that are not specific to a particular version like the versioning control system we use or other infrastructure.
Post Reply
User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 673
Joined: Mon Mar 08, 2010 9:18 am

Standardize Javascript Libraries for phpBB MODs

Post by VSE »

I think it's time phpBB come up with a standard for dealing with MODs that include jQuery (or Motools, Prototype, Dojo, Scriptabulous, etc).

Currently, MOD authors who build MODs using these libraries (no doubt to help their javascript programming, particularly when adding AJAX features to phpBB) usually include the required library with their MODs, and provide instructions to include them at their discretion. This can lead to potential conflicts where Admins might wind up with references to multiple copies of the same library, or conflicting versions - all of which result in breaking the functionality of their MOD or other MODs.

I think phpBB should standardize the use of these libraries by providing a default folder to hold these libraries: root/js_libraries

Then the MOD Author coding guidelines should specify that MODs using these must use this folder to hold their jQuery.js, etc. files. And reference it in the HEAD tag like:

Code: Select all

<script type="text/javascript" src="{ROOT_PATH}js_libraries/jquery.js"></script>
This could help minimize the build up of redundant javascript libraries on their servers, as well as give the Admins an easier way of finding that they may already be using jQuery, etc. when installing a new MOD that also uses it, helping them find and prevent potential conflicts.

Short of making jQuery an intergrated component of phpBB, I think this could be a good solution to what is surely becoming a concern for some Admins and MOD authors.

Any further thoughts, discussion? :D
Has an irascible disposition.

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

Re: Standardize Javascript Libraries for phpBB MODs

Post by Oleg »

What happens when different modifications want different versions of the same library?

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

Re: Standardize Javascript Libraries for phpBB MODs

Post by DavidIQ »

When this topic came up on phpBB.com my first thought was to use a hook and problem would be solved. Unfortunately there are currently no hooks to modify the template output. This is however changing in 3.1 so such hooks could exist. With that in mind we could implement a mandatory use of hooks for adding scripts to the header.

As for having a central location for scripts this should be the case for all JavaScript contained in the forum. I can't think of too many styles that forum_fn.js is different between them yet each style has its own. Same for styleswitcher.js. I think we could just have a single location for all of these, as suggested by VSE, a change that could be implemented in 3.2 although trivial enough and advantageous enough to do in 3.1.
Image

User avatar
VSE
Extension Customisations
Extension Customisations
Posts: 673
Joined: Mon Mar 08, 2010 9:18 am

Re: Standardize Javascript Libraries for phpBB MODs

Post by VSE »

nn- wrote:What happens when different modifications want different versions of the same library?
A naming convention needs to be adopted in the coding guidelines to deal with this. For example, require of MOD authors that version numbers and "min" be removed, so you have just names like:
jquery.js
jquery-ui.js

Because you can not really operate different versions of jQuery at the same time, it should be up to the MOD authors to ensure their MODs are capable of working with the most current version of jQuery. Their MODs can provide a jQuery file. But it should also be the Admin's job when installing MODs to make sure that they are either:
  • a) Keeping the most current version of jQuery in this folder, or...
  • b) Checking the jquery.js file included in a MOD they wish to install and make sure it is NOT an earlier version than their currently in-use jquery.js file (which is easy enough to do as the version number is in the header of the file).
Has an irascible disposition.

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

Re: Standardize Javascript Libraries for phpBB MODs

Post by DavidIQ »

That's going to be kind of hard to do with an automated installer.
Image

Post Reply