Jump to content

Conflicting Javascripts Problem


Guest grumpydave

Recommended Posts

Guest grumpydave

I am designing a CC5 site for myself (at localhost) which requires a few extra jQuery scripts. Almost all of these scripts will not work as they seem to conflict with javascripts already in use by CC5.

Having fiddled around endlessley with CC5 a combination of the following actions puts things in order.

  1. Edit the contents of 'skin_name'/js/common.html. In this file I have removed <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>. The scripts I am adding to CC5 already link to jQuery 1.7.1 in the <head>.
  2. Remove {foreach from=$JS_SCRIPTS key=k item=script}<script type="text/javascript" src="{$script}"></script>{/foreach} from templates/main.php

My concern is that I have disabled some important functions of CC5. I know very litle about javascripts other than how to install them in an html page and make neccessary modifications as instructed. Can anyone explain what the common.html file and the script called at the bottom of main.php actually do and if I can get away with modifying or deleting them?

Thanks.

Link to comment
Share on other sites

  • 2 weeks later...

You only ever need to include the jQuery library once. It gets included from common.html and so it is best to leave this file as it is and simply omit the inclusion of jQuery from any scripts you are adding. In common.html, there are the following inclusions:


<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>

<script type="text/javascript" src="{$STORE_URL}/js/plugins.php"></script>

<script type="text/javascript" src="{$STORE_URL}/js/common.js"></script>





This file is then included into the main.php template file through the statement:





{include file='js/common.html'}

Dealing with each script individually:

  • jquery-ui.min.js - This is the jQuery library that is required.
  • query-ui.min.js - The jQuery UI (User Interface) library. I have no idea why this is in here or if it is even required for the front-end. I have removed this from my themes since it comes with a hefty file size and I don't see why it is necessary.
  • plugins.php - Used to load in all of the JS files from the /js/plugins/ directory. Again, many of the files in there are not required for the front-end but CubeCart loads them in anyway. The only files you will probably need are jquery.colorbox-min.js, jquery.magnifier.js and jquery.rating.min.js. I would remove the inclusion of the plugins.php script and instead include these three scripts in your main.php template file.
  • common.js - Essentially an application file that makes use of all of the plugins included above. You'll probably want to keep this one!

I hope this helps.

Link to comment
Share on other sites

  • 4 weeks later...

Thnx.

I'm struggling for days now to implement a custom jquery header. It does not work. I know it conflicts but even with the information above I still have conflicts. So for now...I'm stucked.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...