Uploaded image for project: 'phpBB3'
  1. phpBB3
  2. PHPBB3-11795

Move all JavaScript from HTML code to external files

    Details

    • Type: Improvement
    • Status: Unverified Fix
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.1.0-dev
    • Fix Version/s: 3.1.0-a1
    • Component/s: Styles
    • Labels:
      None

      Description

      RFC: http://area51.phpbb.com/phpBB/viewtopic.php?f=108&t=44477

      All JavaScript should be moved to external files. It will reduce loading time because browser engine won't have to switch between JS and HTML parsers, it will reduce page size because HTML code will be smaller.

      Variables used by JS should be set via data attributes to appropriate elements.

        Activity

        Hide
        Arty Vjacheslav Trushkin added a comment -

        Patch is not complete yet

        Show
        Arty Vjacheslav Trushkin added a comment - Patch is not complete yet
        Hide
        brunoais brunoais added a comment -

        " It will reduce loading time because browser engine won't have to switch between JS and HTML parsers"
        Is that tested anywhere?

        "it will reduce page size because HTML code will be smaller."
        I wonder about that...

        Show
        brunoais brunoais added a comment - " It will reduce loading time because browser engine won't have to switch between JS and HTML parsers" Is that tested anywhere? "it will reduce page size because HTML code will be smaller." I wonder about that...
        Hide
        Arty Vjacheslav Trushkin added a comment - - edited

        1st point: http://developer.yahoo.com/performance/rules.html see "make javascript external" section that explains it quite well.

        2nd point: javascript will be in forum_fn.js, cached by browser instead of being included in html code.

        Show
        Arty Vjacheslav Trushkin added a comment - - edited 1st point: http://developer.yahoo.com/performance/rules.html see "make javascript external" section that explains it quite well. 2nd point: javascript will be in forum_fn.js, cached by browser instead of being included in html code.
        Show
        Arty Vjacheslav Trushkin added a comment - Also see this: http://en.wikipedia.org/wiki/Unobtrusive_JavaScript
        Hide
        brunoais brunoais added a comment - - edited

        About 1st point:
        Why not make the language keys also external, then?
        A .js file made using php (and returning appropriate headers)

        About 2nd point:
        It makes sense to place the js in forum_fn.js but why is it better to have the javascript translated texts inside data attributes better than having an external js file (with all keys for the user's language) or an included <script> tags with variables with the translation keys required for that page?

        About 3rd point:
        Unrelated to what I'm mentioning (I think).
        Thinking a bit, I believe that what I'm mentioning is actually more unobtrusive than placing as data-* attributes IMO (still... YMMV on that)... And using the external js file made using php may be even more.

        Edit:
        Btw, after reading some parts of that file, I can conclude that it has very outdated parts.
        A good example of that:
        "Unfortunately, Firefox doesn't support the DEFER attribute" (about <script> tags)
        So some things do not make sense anymore even though others still do make a lot of sense.

        Show
        brunoais brunoais added a comment - - edited About 1st point: Why not make the language keys also external, then? A .js file made using php (and returning appropriate headers) About 2nd point: It makes sense to place the js in forum_fn.js but why is it better to have the javascript translated texts inside data attributes better than having an external js file (with all keys for the user's language) or an included <script> tags with variables with the translation keys required for that page? About 3rd point: Unrelated to what I'm mentioning (I think). Thinking a bit, I believe that what I'm mentioning is actually more unobtrusive than placing as data-* attributes IMO (still... YMMV on that)... And using the external js file made using php may be even more. Edit: Btw, after reading some parts of that file, I can conclude that it has very outdated parts. A good example of that: "Unfortunately, Firefox doesn't support the DEFER attribute" (about <script> tags) So some things do not make sense anymore even though others still do make a lot of sense.
        Hide
        Arty Vjacheslav Trushkin added a comment -

        Yes, it does have outdated parts. I can't find recent one published by Chrome devs few months ago that says basically the same.

        What you are suggesting cannot be implemented right now because css and js files aren't parsed. It can be done later after Assetic is implemented, changing it would be much easier after this ticket is merged because all scripts would already be in one place.

        Show
        Arty Vjacheslav Trushkin added a comment - Yes, it does have outdated parts. I can't find recent one published by Chrome devs few months ago that says basically the same. What you are suggesting cannot be implemented right now because css and js files aren't parsed. It can be done later after Assetic is implemented, changing it would be much easier after this ticket is merged because all scripts would already be in one place.
        Hide
        brunoais brunoais added a comment - - edited

        They don't need to be parsed, anyway.

        Just serve as 1 extra cacheable file (the selected "file" is different depending on the language).

        I have already made such thing for a simple program and it is really easy and straight forward, I just wonder about a big program like phpBB, though...

        Show
        brunoais brunoais added a comment - - edited They don't need to be parsed, anyway. Just serve as 1 extra cacheable file (the selected "file" is different depending on the language). I have already made such thing for a simple program and it is really easy and straight forward, I just wonder about a big program like phpBB, though...

          People

          • Assignee:
            EXreaction EXreaction [X] (Inactive)
            Reporter:
            Arty Vjacheslav Trushkin
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development