Post by kishmish » Thu Jul 26, 2012 12:17 am

HI
is there a way to remove extra javascript codes from my opencart site?
So how i can remove javascript codes from site as SEO point of view it's too bad for us

New member

Posts

Joined
Thu Apr 12, 2012 11:00 pm

Post by uksitebuilder » Thu Jul 26, 2012 5:27 am

Not sure what you mean by extra javascript.

Javascript is integral to the fuctionality of OpenCart. It simply will not function without javascript without a major rewrite of the core code

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by kishmish » Thu Jul 26, 2012 9:07 am

Thanks to reply
actually i want to move internal javascript to external file , such as some module like currency converter has javascript in his own files like .tpl files i need to move them in external files and how i call them please

New member

Posts

Joined
Thu Apr 12, 2012 11:00 pm

Post by uksitebuilder » Thu Jul 26, 2012 2:55 pm

OK, I see now what you mean.

try moving the code to an external file and then reference it

Code: Select all

<script type="text/javascript" src="link/to/external/file.js"></script>
Please know that some javascript needs to be in the position it is within tpl files etc and cannot simply be moved to the HEAD or FOOTER

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by kishmish » Thu Jul 26, 2012 5:39 pm

thanks for reply
i did it according to your instructions but it does not work, following is the code which i need to move in external file from internal file of currency converter module see this code of tpl file
javascript code was at end and then i move it to another file and reference it like that please see....

Code: Select all

<div class="box">

  <div class="box-heading"><?php echo $heading_title; ?></div>

  <div class="box-content">

    <div class="box-currency">

     	<div class="c-amount">

			<?php echo $text_amount; ?>

			<input style="text-align:right" type="text" size="10" value="<?php echo $currency_value; ?>" name="currency_value"/>

		</div>

		<div class="c-from">

			<?php echo $text_from; ?><br />

			<select  style="max-width:160px" name="currency_from">

						<?php foreach($currencies as $currency){ ?>

							<option <?php echo ($currency['currency_code'] == $currency_from) ? 'selected="selected"' : ''; ?> value="<?php echo $currency['currency_code']; ?>"><?php echo $currency['currency_name'].'('.$currency['country_code'].')';?></option>

						<?php } ?>

					</select>

		</div>

		<div class="c-to">

			<?php echo $text_to;?><br />

			<select style="max-width:160px" name="currency_to">

						<?php foreach($currencies as $currency){ ?>

							<option <?php echo ($currency['currency_code'] == $currency_to) ? 'selected="selected"' : ''; ?> value="<?php echo $currency['currency_code']; ?>"><?php echo $currency['currency_name'].'('.$currency['country_code'].')';?></option>

						<?php } ?>

					</select>

		</div><br />

		<div style="text-align:center" class="converter">

		<div id="c-loadding"></div>

		<a class="button" id="goconverter" ><span><?php echo $text_converter;?></span></a>

		</div><br />

		<div class="c-results">

		 <p class="prices">	<?php echo $currency_value.$currency_from.' = '.$currencyconverter['amount'].$currency_to; ?></p>

		 <p style="font-size:10px"><?php echo $text_rate.$currencyconverter['date'].' '.$currencyconverter['time']; ?></p>

		</div>

    </div>

  </div>

</div>


<script type="text/javascript" src="catalog/view/theme/default/template/module/currencyconverter.js"></script>

Javascript code is following which i grab from above file at the bottom

Code: Select all

<script type="text/javascript"><!--

$('a#goconverter').bind('click',function(){

	$.ajax({

		type: 'POST',

		url: 'index.php?route=module/currencyconverter',

		data: 'currency_value=' + encodeURIComponent($('input[name=\'currency_value\']').val()) + '&currency_from=' + encodeURIComponent($('select[name=\'currency_from\']').val()) + '&currency_to=' + encodeURIComponent($('select[name=\'currency_to\']').val()),

		dataType: 'json',

		beforeSend: function() {

		$('#c-loadding').html('<img src="catalog/view/theme/default/image/loading.gif" id="loading" style="padding-left: 5px;" />');

	},

		success:function(json){

			if(json.error)

			{

				$('.c-results').html('<p style="color:red">'+json.error+'</p>');

				$('#c-loadding').html('');

			}

			if(json.currencyconverter)

			{

				var html = '';

				html += '<p class="prices">';

				html += json.currency_value + json.currency_from;

				html += ' = '+ json.currencyconverter['amount'] +'';

				html += json.currency_to;

				html += '</p>';

		 		html += '<p style="font-size:10px">';

				html += '<?php echo $text_rate; ?>';

				html += json.currencyconverter['date']+json.currencyconverter['time'];

				html += '</p>';

				$('.c-results').html(html);

				$('#c-loadding').html('');

			}

		}

	})

});

//--></script> 

New member

Posts

Joined
Thu Apr 12, 2012 11:00 pm

Post by uksitebuilder » Thu Jul 26, 2012 5:57 pm

Try removing the first and last lines in you .js file as they should not be there

If it still doesn't work after that, I'm guessing that it is important that some js code needs to be left inline, which is probably why Daniel did it that way.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by kishmish » Fri Jul 27, 2012 7:47 am

Another problem is i need to remove welcome content in error page here i show you code of not_found.tpl code...
when i remove <?php echo $content_bottom; ?> it disappear all bottom cotent but i just need to remove welcome content from that page and search page..is there way to solve this?

<?php echo $header; ?>

<div class="container"><?php echo $content_top; ?><?php echo $column_left; ?><?php echo $column_right; ?>

<div id="content">

<div class="breadcrumb">

<?php foreach ($breadcrumbs as $breadcrumb) { ?>

<?php echo $breadcrumb['separator']; ?><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a>

<?php } ?>

</div>

<h1><?php echo $heading_title; ?></h1>

<div class="content"><?php echo $text_error; ?></div>

<!--<div class="buttons">

<div class="right"><a href="<?php echo $continue; ?>" class="button"><span><?php echo $button_continue; ?></span></a></div>

</div>--!>

<?php echo $content_bottom; ?>

</div>

<?php echo $footer; ?>

New member

Posts

Joined
Thu Apr 12, 2012 11:00 pm

Post by uksitebuilder » Fri Jul 27, 2012 5:12 pm

Not sure what you mean by welcome content - A screenshot may help ?

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by uksitebuilder » Fri Jul 27, 2012 8:24 pm

If you are referring to the Welcome module, then you specify which pages to include it on.

in your admin, go in to Extensions -> Modules -> Welcome and make sure you only have it set to appear on your home page.

ImageImageImageImageImage

For Friendly Professional Support - Click Here


User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by Ljubo » Fri Sep 14, 2012 3:08 pm

Similar question to the original posting...
I probably do have some extra javascripts, either called from the files and not used anywhere, or .js files that exist but not even called from anywhere.
what would be the best way to check for those files in order to just delete them and speed up a bit the loading time?
thank you...
I am talking about customized oc installation.

Active Member

Posts

Joined
Mon Jan 31, 2011 10:07 pm
Location - Serbia

Post by appsfinder » Wed Jul 16, 2014 11:45 pm

Hi what javascript can be removed that without breaking open cart i.e. what i don't want to use

eg jquery.jcarousel.min.js ,jquery.nivo.slider.pack.js jquery.colorbox.js

what files and code needs to be deleted?

:) open cart 2.3.0.2 & 3.0.3.2


New member

Posts

Joined
Fri Feb 08, 2013 4:12 am

Post by OSWorX » Wed Jul 16, 2014 11:52 pm

appsfinder wrote:Hi what javascript can be removed that without breaking open cart i.e. what i don't want to use

eg jquery.jcarousel.min.js ,jquery.nivo.slider.pack.js jquery.colorbox.js

what files and code needs to be deleted?
Depends on what modules you do not need anymore.
carousel & nivo = product presentation & manufactors
colorbox = popup windows (e.g. TOS at checkout)

Forum Rules [en]: viewtopic.php?f=176&t=200480
Forumregeln [de]: viewtopic.php?f=37&t=114208
Commercial Request: viewforum.php?f=88

Image Image Image


User avatar
Guru Member
Online

Posts

Joined
Mon Jan 11, 2010 10:52 pm
Location - Austria
Who is online

Users browsing this forum: OSWorX and 5 guests