View Full Version : top javascript
camiller
Dec-25-2008, 09:23 AM
Happy Holidays!
Other than the speed at which the site will load is there any other reasons not to use the "top javascript" container? I duplicated the code to change "gallery comments" to "guestbook comments" for my about me page. However, it will only change one of the pages if both sections are in the bottom javascript. When I put the about me javascript in the top javascript area it works for both pages.
Is that okay or is there some other reason not to put things in the top javascript container? If so, how do I make both work in the bottom area?
Thanks,
jfriend
Dec-25-2008, 10:13 AM
Your javascript should be in the bottom.
Reasons to put things in Bottom javascript:
An error in your javascript if it's in the top may cause your entire gallery not to display. An error if it's in the bottom will not affect your gallery display
Your galleries, categories and homepage will display faster if you put your JS in the bottom javascript
If you are trying to modify the page directly, the page is not yet loaded when the top javascript section loads so your code may not work if it's in the top.Reasons to put things in Top javascript:
If you need to set a default configuration variable before the gallery loads
If you need javascript that is available when the custom header loads
If you need javascript that runs before the page displays (an example of this is vanity URLs).If you aren't sure where to put it, put it in the bottom.
I took a look and all of your javascript should be in the bottom javascript area. One thing that is probably confusing you is you have two copies of almost the same code in your bottom javascript and only one of those copies is active (the last one wins). The problem is that you have two copies of ModifyText, each set for a different gallery. That won't work. There are more elegant ways to solve this problem, but the simplest is to just change one of those copies to have a name of "ModifyText2" and then change it's corresponding line to:
YE.onAvailable("comment", ModifyText2);
Then, each copy of the function will work separately for both your About page and your Guestbook page. Currently, only one or the other will work depending upon the order of your javascript.
camiller
Dec-25-2008, 11:13 AM
Your javascript should be in the bottom.
Reasons to put things in Bottom javascript:
An error in your javascript if it's in the top may cause your entire gallery not to display. An error if it's in the bottom will not affect your gallery display
Your galleries, categories and homepage will display faster if you put your JS in the bottom javascript
If you are trying to modify the page directly, the page is not yet loaded when the top javascript section loads so your code may not work if it's in the top.Reasons to put things in Top javascript:
If you need to set a default configuration variable before the gallery loads
If you need javascript that is available when the custom header loads
If you need javascript that runs before the page displays (an example of this is vanity URLs).If you aren't sure where to put it, put it in the bottom.
I took a look and all of your javascript should be in the bottom javascript area. One thing that is probably confusing you is you have two copies of almost the same code in your bottom javascript and only one of those copies is active (the last one wins). The problem is that you have two copies of ModifyText, each set for a different gallery. That won't work. There are more elegant ways to solve this problem, but the simplest is to just change one of those copies to have a name of "ModifyText2" and then change it's corresponding line to:
YE.onAvailable("comment", ModifyText2);
Then, each copy of the function will work separately for both your About page and your Guestbook page. Currently, only one or the other will work depending upon the order of your javascript.
Thanks John - changed second copy to ModifyText2 and now they both work. Won't mess with top javascript unless I ask first. Thanks again.
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.