Hum... I think INCLUDEJS shouldn't place the scripts in the footer by se. It should place the scripts right after jQuery or leave where they are at the moment.
There are scripts that simply do not need jQuery so there is no need to have control when they are included and may just be included where they are.
I was thinking of:
INCLUDEJS -> Includes the js somewhere that, anyway, assures that it is under jQuery
INCLUDEJS_HERE -> Includes the js in that exact place (it's like having the <script> tag right now. This works exclusively as a replacement system to find the .js file)
And there should be a tag where you mark the place where the scripts are meant to be placed. I don't know if there's already but I don't remember reading that.
This should not loose the order the scripts appear in the page (easy to implement, anyway) there are many times where this is crucial.
BTW: Placing many scripts in the bottom is a bad idea (not so bad as placing them in the head without defer) but it's bad, anyway. I already had situations where the page seem loaded and get irritated when I try something that uses js and nothing happens. E.g. I press the delete post button but, as script didn't execute yet, it shows me the delete post page and not the js counterpart. This is a simple example, but with more complex stuff the thing can be annoying.
[RFC|Merged] Template tag to include JS files
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Template tag to include JS files
Please keep your defer rubbish to the defer thread.
If a style author wants to include a script where it is… they can use a script tag
If a style author wants to include a script where it is… they can use a script tag
Re: [RFC] Template tag to include JS files
What about if "I", template maker, want to use a script tag that comes from one my template's parents?callumacrae wrote:Please keep your defer rubbish to the defer thread.
If a style author wants to include a script where it is… they can use a script tag
How do I solve that specific problem? Do I need to know exactly where that file is?
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Template tag to include JS files
JavaScript should go in the footer, anyway
Re: [RFC] Template tag to include JS files
brunoais, I think you are missing the point of INCLUDEJS. If someone wants to keep script in specific place, he can use <script> tag. INCLUDEJS's purpose is to add script to footer after jQuery, so script would be included after jQuery and could use jQuery.
Formerly known as CyberAlien.
Free phpBB styles | Premium responsive XenForo styles | Iconify - modern open source replacement for glyph fonts
Free phpBB styles | Premium responsive XenForo styles | Iconify - modern open source replacement for glyph fonts
Re: [RFC] Template tag to include JS files
Let's see...
It's still not 100% decided if jQuery will be in the footer anyway.
If it wasn't thought, I think this INCLUDEJS system should work with the parent child to allow the parent of the parent, etc... to have the real script that is included in the file.
The objective is to have this job completely simplified. There was already another tag that, IIRC, was discussed and dropped. I'm supposing this is the replacement.
As a thing like that, it should support the 100% sure it'll be under under jQuery (like now) and it should support let it be placed here.
(I'm not going to press the same button again (only mention it) (defer))
We could have a tag that tells: jQuery is here.
Where that tag is placed, the script tag for jQuery is placed all the accumulated script tags are written and a variable is set to true. After that there is no difference between the tag that inserts the script in that place and that inserts after jQuery.
With this:
If you place the marker in the footer, scripts set to appear after jQuery appear only in the footer after jQuery.
If the marker is in the head then all scripts that are in the body appear where they are.
Anyway, this really requires a partial rewrite of editor.js. I already have an idea about that in my proposal for the use of defer. There's a great possibility that there is a better solution. Anyway I will not lose to an opinion to choose worse options than mine without a fight.
It's still not 100% decided if jQuery will be in the footer anyway.
If it wasn't thought, I think this INCLUDEJS system should work with the parent child to allow the parent of the parent, etc... to have the real script that is included in the file.
The objective is to have this job completely simplified. There was already another tag that, IIRC, was discussed and dropped. I'm supposing this is the replacement.
As a thing like that, it should support the 100% sure it'll be under under jQuery (like now) and it should support let it be placed here.
(I'm not going to press the same button again (only mention it) (defer))
We could have a tag that tells: jQuery is here.
Where that tag is placed, the script tag for jQuery is placed all the accumulated script tags are written and a variable is set to true. After that there is no difference between the tag that inserts the script in that place and that inserts after jQuery.
With this:
If you place the marker in the footer, scripts set to appear after jQuery appear only in the footer after jQuery.
If the marker is in the head then all scripts that are in the body appear where they are.
Anyway, this really requires a partial rewrite of editor.js. I already have an idea about that in my proposal for the use of defer. There's a great possibility that there is a better solution. Anyway I will not lose to an opinion to choose worse options than mine without a fight.
Re: [RFC] Template tag to include JS files
it makes sense to put all code used in one unified place. if we want to put the library stuff in a different place then the theme code finei could be ok with
The inclusion of jQuery recieved heavy weight from myself and igorw during the modernization for the theme as current js for the theme is using very bad practices and jQuery provided an easy simple method to eliviate this but unfortunately it requires converting all of these inline event handles of which their are hundreds which point to several different functions of which I myslef am not 100% what are doing as they were horibbly coded(lack of comments or standardization throught). I have been recently working on going through and one by one reworking all of these but it is a long and arguis process
By doing a to complete strip of the JS from the template files so that we are not attaching onclick events to HTML elements via inline but rather caching them and adding events to them in one easy to edit and contoroled location we are seperating the JS from the template to allow theme authors to easily change any aspect of the theme without breaking the JS
having the chached dom elements required for the JS in the footer or in its own file that we include via this method in the footer allows them to easily change the pointer to the dom element they created. It also allows us to essentially wrap all the jQuery with in the jQuery object protecting us for use of all JS. Putting them in the header is quite comfusing as its in the middle of all the HTML where as the footer it is litteraly above 2 html tags body close and html close wmaking it cleaner and easier to work with, exspecially for a novice coder
The inclusion of jQuery recieved heavy weight from myself and igorw during the modernization for the theme as current js for the theme is using very bad practices and jQuery provided an easy simple method to eliviate this but unfortunately it requires converting all of these inline event handles of which their are hundreds which point to several different functions of which I myslef am not 100% what are doing as they were horibbly coded(lack of comments or standardization throught). I have been recently working on going through and one by one reworking all of these but it is a long and arguis process
By doing a to complete strip of the JS from the template files so that we are not attaching onclick events to HTML elements via inline but rather caching them and adding events to them in one easy to edit and contoroled location we are seperating the JS from the template to allow theme authors to easily change any aspect of the theme without breaking the JS
having the chached dom elements required for the JS in the footer or in its own file that we include via this method in the footer allows them to easily change the pointer to the dom element they created. It also allows us to essentially wrap all the jQuery with in the jQuery object protecting us for use of all JS. Putting them in the header is quite comfusing as its in the middle of all the HTML where as the footer it is litteraly above 2 html tags body close and html close wmaking it cleaner and easier to work with, exspecially for a novice coder
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Template tag to include JS files
Just had a thought; template/ajax.js should be the last file to be included.
Re: [RFC] Template tag to include JS files
Not a problem, it can be included in footer in this order:callumacrae wrote:Just had a thought; template/ajax.js should be the last file to be included.
Include jQuery
Include core.js from assets
<!-- INCLUDEJS ajax.js -->
{SCRIPTS}
Formerly known as CyberAlien.
Free phpBB styles | Premium responsive XenForo styles | Iconify - modern open source replacement for glyph fonts
Free phpBB styles | Premium responsive XenForo styles | Iconify - modern open source replacement for glyph fonts
- callumacrae
- Former Team Member
- Posts: 1046
- Joined: Tue Apr 27, 2010 9:37 am
- Location: England
- Contact:
Re: [RFC] Template tag to include JS files
Other way round
core.js, then {SCRIPTS}, then ajax.js
EDIT: Ignore that, you're using INCLDEJS. Why are you using INCLUDEJS? XD
core.js, then {SCRIPTS}, then ajax.js
EDIT: Ignore that, you're using INCLDEJS. Why are you using INCLUDEJS? XD