Get XOOPS XOOPSXOOPS FAQFAQ ForumsForums NewsNews ThemesThemes ModulesModules
New Posts New Topics All Posts All Forums Index General Modules Themes Development International XOOPS.org

Search

Donat-O-Meter

Make donations with PayPal!
Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $65.00
Net Balance: $61.80
Left to go: $38.20

Donations
studioC  ($25)May-17
Anonymous ($15)May-16
Anonymous ($25)May-4

Learn XOOPS Core

Local Support

Advertisement

XOOPS Code hosted on SourceForge

Cumulus Tag Cloud

2 2.5 2.6 3.0 2013 Abuse adslight AntiHarvesting AntiMalUser AntiSpam API Australia Ban banner Beats billige black Blocks blue Captcha cell Christmas chronolabs content Conversion database demo docek download Dresses editor evden eve facebook Federated floor free Gateway herre Honeypot Human IP jQuery kantor lamps Legal log logger mobile module modules Monster MyAlbum-p Networks newbb news Notices online PageRank pdf Permissions pink Plugin portal Prevention profile project Protector publisher release Rights rmcommon Room sale security SERIAL Server site Smarty Spam statistics stem Studio tag tags tdmcreate template Theme themes userlog website Whitepaper XML XooLaT xoops Xoopspoll Xortify xthemes Yolande ZendFramework

New Users

Registering user

# 136015

handrick12

Welcome to XOOPS!




Bottom   Previous Topic   Next Topic  Register To Post

(1) 2 »


#1 Posted on: 2010/12/24 22:14 jquery being loaded multiple times
I am currently working on a new theme for my website. The website uses mymenus and publisher. Looking at the source of one of the pages in the head section I see that jquery is being loaded three times, one each by the theme, mymenus and publisher. Also there are multiple .js files being loaded.

Is there a way that I can prevent the multiple loading of jquery. What are the changes that I need to make in mymenus and publisher module to stop loading the jquery so that the modules can use the jquery loaded by the theme?

Top


Nitin Shah
Most problems in world are result of poor communication
nmshah
Just can't stay away
Just can't stay away
Joined:
2007/7/2 3:24
Group:
Registered Users
Posts: 544
(Show More) (Show Less)


#2 Posted on: 2010/12/25 4:21 Re: jquery being loaded multiple times
Add jquery like this in your theme heder :

<{php}>
/** add JQuery and JQuery UI */
    
global $xoTheme
        
$xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
        
$this->assign('xoops_module_header'$xoTheme->renderMetas(nulltrue)); 
<{/
php}>


looking to suico theme . I have this problem too and I found just this way .

in extgallrey I add a option for enables/disables jQuery . perhaps we need a option like this for all part of user side

Top


Persian Support Site
voltan
Theme Designer
Theme Designer
Joined:
2006/12/5 11:55
From Tehran
Group:
Registered Users
Designer Group
Posts: 549
(Show More) (Show Less)


#3 Posted on: 2010/12/25 6:24 Re: jquery being loaded multiple times
Voltan I think it's an error in mymenus, me too I have the same thing

Top


the road of success is always under construction
mariane
Theme Designer
Theme Designer
Joined:
2008/1/11 9:31
From Lebanon
Group:
Registered Users
Designer Group
Posts: 483
(Show More) (Show Less)


#4 Posted on: 2010/12/26 3:06 Re: jquery being loaded multiple times
check mymenus whit default theme or theme whit out jQuery .

in my menu jQuery add whti this cood and in php file :
$xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");

and in theme jQuery added whit
<script type="text/javascript" src="<{xoAppUrl browse.php?Frameworks/jquery/jquery.js}>"></script>


and in page source you have 2 jQuery and some of the code's between jQuery1 and jQuery2 do not work

Top


Persian Support Site
voltan
Theme Designer
Theme Designer
Joined:
2006/12/5 11:55
From Tehran
Group:
Registered Users
Designer Group
Posts: 549
(Show More) (Show Less)


#5 Posted on: 2010/12/26 5:29 Re: jquery being loaded multiple times
Thanks Voltan & Marine for helping and confirming

What changes should i make in mymenu codes to prevent it from loading the jquery? I will like to simply remove the line/code that loads the jquery.

I am using superfish skin

Top


Nitin Shah
Most problems in world are result of poor communication
nmshah
Just can't stay away
Just can't stay away
Joined:
2007/7/2 3:24
Group:
Registered Users
Posts: 544
(Show More) (Show Less)


#6 Posted on: 2010/12/26 9:05 Re: jquery being loaded multiple times
It is bad programming practice to load something like jquery without first checking if it is already loaded. You should add PHP code prior to loading jquery to make sure if it is already loaded or not. Only load if it is necessary.

I have yet to mess with jquery myself but this is a good programming practice for any program like this.

If you can ask for the version of jquery that is loaded that is the easiest way to determine if it is loaded or not.

I am blindly responding to this as I have no current experience with jquery however this would be similar to using "require once" which only loads a PHP include file if it hasn't been loaded yet.

Rodney


Top


Attending College working towards Bachelors in Software Engineering and Network Security.
redheadedrod
Home away from home
Home away from home
Joined:
2008/2/26 10:05
From Grand Rapids, MI
Group:
Registered Users
Posts: 1065
(Show More) (Show Less)


#7 Posted on: 2010/12/26 11:35 Re: jquery being loaded multiple times
in your theme jq loaded like this:
<script type="text/javascript" src="<{xoAppUrl browse.php?Frameworks/jquery/jquery.js}>"></script>


remove it and add thsi code in your theme:
<{php}>
/** add JQuery and JQuery UI */
    
global $xoTheme
        
$xoTheme->addScript("browse.php?Frameworks/jquery/jquery.js");
        
$this->assign('xoops_module_header'$xoTheme->renderMetas(nulltrue)); 
<{/
php}>


Top


Persian Support Site
voltan
Theme Designer
Theme Designer
Joined:
2006/12/5 11:55
From Tehran
Group:
Registered Users
Designer Group
Posts: 549
(Show More) (Show Less)


#8 Posted on: 2011/4/19 3:06 Re: jquery being loaded multiple times
the code works but I've a problem with mymenu module...
the code for the jscript menu in the module's header is loaded before the jquery call made by theme..
this creating an error in page loading..

I think it's a 'bug' related to how the skins load jscript code (which is not via the addScript method,
any idea on how can I solve this?

Ian


Top


Xoops Italian Support Staff Member || My playground for Xoops
ianez
Not too shy to talk
Not too shy to talk
Joined:
2006/1/26 10:56
Group:
Registered Users
Posts: 178
(Show More) (Show Less)


#9 Posted on: 2011/4/19 8:15 Re: jquery being loaded multiple times
At modules/mymenus/skins/YOUR_SELECT_SKIN/skin_version.php you can find js files and edit this

Top


Persian Support Site
voltan
Theme Designer
Theme Designer
Joined:
2006/12/5 11:55
From Tehran
Group:
Registered Users
Designer Group
Posts: 549
(Show More) (Show Less)


#10 Posted on: 2011/4/19 9:23 Re: jquery being loaded multiple times
hi Voltan,
the problem is exactly that the code of mymenu skins call a jquery instance improperly inserting a link to a js folder in the module not using the addScript method..
so when I use a mymenu block with jquery and I open a fmcontent page with uses lightbox the result is this

<script src="http://localhost/xoops250/include/xoops.js" type="text/javascript"></script>

<script type="text/javascript" src="http://localhost/xoops250/class/textsanitizer/image/image.js"></script>
<script src="http://localhost/xoops250/modules/mymenus/skins/superfish/../../js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="http://localhost/xoops250/modules/mymenus/skins/superfish/../../js/hoverIntent.js" type="text/javascript"></script>
<script src="http://localhost/xoops250/modules/mymenus/skins/superfish/../../js/superfish.js" type="text/javascript"></script>
<script src="http://localhost/xoops250/browse.php?Frameworks/jquery/jquery.js" type="text/javascript"></script>
<script src="http://localhost/xoops250/browse.php?Frameworks/jquery/plugins/jquery.lightbox.js" type="text/javascript"></script>
<script src="http://localhost/xoops250/browse.php?Frameworks/jquery/plugins/jquery.ui.js" type="text/javascript"></script>


as you may see the jquery instance of the skin breaks the following.. (lightbox is not working in this case..).. how can I call jscriptin mymenuskin using the right addScript method?

Ian

Top


Xoops Italian Support Staff Member || My playground for Xoops
ianez
Not too shy to talk
Not too shy to talk
Joined:
2006/1/26 10:56
Group:
Registered Users
Posts: 178
(Show More) (Show Less)




(1) 2 »



You can view topic.
You cannot start a new topic.
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.

[Advanced Search]