*Note This is part 13 of a series found here
We need to ensure that their are no JS calls from within the html. A simple search for click=" returns "81 matches across 38 files"
Through the proper use of jQuery and the INCLUDEJS feature we should be able to ensure that all the JS is completely abstracted.
I would take a step further and ensure that we are shipping a linted/minified/compressed version as well thats linked to by default.
Thoughts and suggestions
****UPDATE****
Created a Ticket to address one of the separation issues somewhat by transitioning to js- appended for all hooks that will not have css applied to them for better clarity when making changes to the HTML and CSS
Ticket: https://tracker.phpbb.com/browse/PHPBB3-12806
[Define New Theme] 13. All JS needs to be completely abstracted from the template files.
Forum rules
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.
If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
Please do not post support questions regarding installing, updating, or upgrading phpBB 3.3.x. If you need support for phpBB 3.3.x please visit the 3.3.x Support Forum on phpbb.com.
If you have questions regarding writing extensions please post in Extension Writers Discussion to receive proper guidance from our staff and community.
[Define New Theme] 13. All JS needs to be completely abstracted from the template files.
Last edited by hanakin on Fri Jul 04, 2014 11:13 am, edited 3 times in total.
-
- Registered User
- Posts: 523
- Joined: Sat Apr 22, 2006 10:29 pm
- Contact:
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
For those of us that doesn't know the benefit of what you're proposing, please explain
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
their are a number of benefits to this.
- complete division of labor. That is js/css/html all should have their own development lane that does not influence the other.
- keeps the html clean and semantic
- speed up page loads due to minified and compress code utilizing as few of server requests as possible
- consistency. we are using the proper method in some places but not in others
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
I agree fully on removing all instances of the "on*" attributes in the HTML and to use the events interface only.
I do not get, however, is what do you really mean of doing the js separated from the HTML. They are all interconnected! A piece of js is made for a piece of HTML, there's no real way around it.
I do not get, however, is what do you really mean of doing the js separated from the HTML. They are all interconnected! A piece of js is made for a piece of HTML, there's no real way around it.
-
- Registered User
- Posts: 523
- Joined: Sat Apr 22, 2006 10:29 pm
- Contact:
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
I mean that it does not rely on a call in the html it should be event driven as you said. I should not have to worry about all three at the same time as most teams will have a designer who will do the html and css and a developer do the js.brunoais wrote:I agree fully on removing all instances of the "on*" attributes in the HTML and to use the events interface only.
I do not get, however, is what do you really mean of doing the js separated from the HTML. They are all interconnected! A piece of js is made for a piece of HTML, there's no real way around it.
when coding html I should be focused on content and not interactivity
when i code css I should be worried about look and feeling
when i code js I focus on interactivity, I develop the functionality based on the content and the design.
I then add the necessary event hooks followed by any css to render it
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
Same reason you don't mix PHP and HTML.brunoais wrote:I do not get, however, is what do you really mean of doing the js separated from the HTML. They are all interconnected! A piece of js is made for a piece of HTML, there's no real way around it.
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
(considering PHP as the seelcted server side language) You need to mix PHP and HTML in the same file in order to produce dynamic output in a reasonable amount of time. Otherwise, how do you expect to work with that?
Placing files on the side, load the files, replace a huge amount of data in them using PHP for the logic and then outputting to the browser? That's dead slow!
Placing files on the side, load the files, replace a huge amount of data in them using PHP for the logic and then outputting to the browser? That's dead slow!
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
With a templating engine? 0_obrunoais wrote:(considering PHP as the seelcted server side language) You need to mix PHP and HTML in the same file in order to produce dynamic output in a reasonable amount of time. Otherwise, how do you expect to work with that?
Placing files on the side, load the files, replace a huge amount of data in them using PHP for the logic and then outputting to the browser? That's dead slow!
Maybe I should have said you should keep the logic of the PHP separate from the HTML.
Re: [Define New Theme] 13. All JS needs to be completely abstracted from the template files.
Ah yes. I seriously agree with you on that. When I develop anything in PHP I take that into account. There still needs to be some logic in the "output files" but it is quite minor, only the parts that are required such that there's no HTML output from outside those files (mostly the same as the logic in phpBB's template .html files).
Yeah, now I understand what you meant.
I still don't really know about the usage of templating engines unless you really want to make something with plug&play templates (such as phpBB) but I definitely agree that it needs to be organized otherwise, it's a mess to find whatever one wants something. Placing loads of logic in the files responsible for the output just makes it harder to find what matters when changing HTML is required.
Yeah, now I understand what you meant.
I still don't really know about the usage of templating engines unless you really want to make something with plug&play templates (such as phpBB) but I definitely agree that it needs to be organized otherwise, it's a mess to find whatever one wants something. Placing loads of logic in the files responsible for the output just makes it harder to find what matters when changing HTML is required.