[RFC|Merged] Inclusion of jQuery

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.
User avatar
naderman
Consultant
Posts: 1727
Joined: Sun Jan 11, 2004 2:11 am
Location: Berlin, Germany
Contact:

Re: [RFC] Inclusion of jQuery

Post by naderman »

Can you give us any data to back that claim up?

I found http://stackoverflow.com/questions/2814 ... patibility which seems to suggest the same. So even upgrades from 1.6 to 1.7 in a phpBB point release seem ok.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC] Inclusion of jQuery

Post by callumacrae »

Actually, looking at the 1.6 release notes, I seem to be wrong (dunno how I didn't see it before). It's very minor, but it has broken backwards compatibility in a few cases - multiple words in data attributes and .prop.
Made by developers, for developers!
My blog

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

Re: [RFC] Inclusion of jQuery

Post by igorw »

Yes, there were some minor BC breaks in 1.6. The data- stuff doesn't really affect any user code (as you'd be using .data() anyway, which abstracts it away). Regarding .prop(), you should have been using . attr() to begin with.

So really, I'm not all too concerned. When upgrading an existing app from 1.5 to 1.6 I only had a single line that had to be adjusted (of a very js-heavy app).


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

Re: [RFC|Merged] Inclusion of jQuery

Post by igorw »

Great, thanks.

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: [RFC|Merged] Inclusion of jQuery

Post by Arty »

I think its a very bad idea to include jquery in footer.

This means jquery cannot be used in any javascript files included in header, so style and mod authors will have to include js files in footer, making footer cluttered. In extreme cases, like if style author would like to include css file based on detected browser capabilities, it will have to be done in header, so style author won't be able to use jquery for it.

Including jquery file in footer won't speed things up because this is not kind of file that can be loaded asynchronously. Other js files rely on it. It makes sense only for js files that are asynchronous, like statistics and ads, not for jquery.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC|Merged] Inclusion of jQuery

Post by callumacrae »

Arty wrote:I think its a very bad idea to include jquery in footer.

This means jquery cannot be used in any javascript files included in header, so style and mod authors will have to include js files in footer, making footer cluttered. In extreme cases, like if style author would like to include css file based on detected browser capabilities, it will have to be done in header, so style author won't be able to use jquery for it.

Including jquery file in footer won't speed things up because this is not kind of file that can be loaded asynchronously. Other js files rely on it. It makes sense only for js files that are asynchronous, like statistics and ads, not for jquery.
It won't make the footer cluttered any more than it would make the header cluttered. In what cases would an author need to include a CSS file based on browser? The only thing I can think of is IE fixed, and IE has stuff for that.

It will give the appearance of a faster page rendering time. JavaScript isn't usually needed on page load (especially for a forum - if it is, you're doing something wrong), and any JavaScript that isn't need on page load should always go into the footer. Imagine the following situations:

Page partially rendered (no content)
JavaScript rendered (potentially a long time, it's a big file (0.8s on my connection))
JavaScript executed (probably just a load of $(document).ready() calls, which are not needed in the footer)
Page rendered

Or:

Page rendered fully, content viewable
JavaScript rendered
JavaScript executed

If JavaScript were in the header, I would have to wait an additional 0.8s before I could view the content. I'm sure you can appreciate how long that is if I'm visiting thousands of pages a day.
Made by developers, for developers!
My blog

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: [RFC|Merged] Inclusion of jQuery

Post by Arty »

callumacrae wrote:The only thing I can think of is IE fixed, and IE has stuff for that.
IE10 doesn't, and I'm sure people will have to use hacks for it many years later. Unless Microsoft changes its policy to force browser updates on users who use old browsers (which I don't see happening), there will still be people using IE10 5+ years after IE11 release. IE10 in its current state is behind other browsers before its even released, in few years it will be outdated and hacks might be required to implement whatever new stuff will be added to newer browsers. But its a minor issue and probably phpBB 4 will be out before then, so when it will be really needed, jquery could be moved to header.
callumacrae wrote:It will give the appearance of a faster page rendering time. JavaScript isn't usually needed on page load (especially for a forum - if it is, you're doing something wrong), and any JavaScript that isn't need on page load should always go into the footer.
Then what's the use of jQuery in phpBB if its not needed during load? For ajax? Including whole library just for ajax functions is silly.

If jQuery is included in default style, it doesn't make sense not to rewrite other js files (forum_fn.js and editor.js) with jQuery to reduce its size. However, that leads to problem: editor.js is included in posting template, which is shown before footer, so it can't use jQuery.

Some mods might want to use jQuery and include its javascript files only on mod's pages (like calendar, gallery, portal), but it would require adding code to footer instead of mod's templates.

User avatar
callumacrae
Former Team Member
Posts: 1046
Joined: Tue Apr 27, 2010 9:37 am
Location: England
Contact:

Re: [RFC|Merged] Inclusion of jQuery

Post by callumacrae »

Hang on, why would you need jQuery to detect a bowser?

JavaScript of any sort should not be used to render the page, that should all be done server side - otherwise what will people with js disabled do? jQuery is currently being used for AJAX, animations, DOM manipulation (the best thing about jQuery) and parsing forms. It will definately be used more in the future - I know quite a lot of modifications and styles use it.
Made by developers, for developers!
My blog

User avatar
Arty
Former Team Member
Posts: 985
Joined: Wed Mar 06, 2002 2:36 pm
Location: Mars
Contact:

Re: [RFC|Merged] Inclusion of jQuery

Post by Arty »

$.browser, but its a minor issue and workarounds can be easily added. Main issue is inability to use jquery in files included before jquery: so mod's template files, posting editor, forum_fn.js can't use jquery without all being moved to footer. Mods will have to edit footer instead of having links to its js files contained within its template files. If style author would like to add some template specific code (popular example would be collapsing categories), he won't be able to use jquery events in template.

Its bad because putting jquery in footer makes jquery unusable in other templates.

Post Reply