VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: VampiRUS on May 06, 2015, 02:00:15 AM

Title: speedup child product loading
Post by: VampiRUS on May 06, 2015, 02:00:15 AM
Hi.
If in
components\com_virtuemart\assets\js\dynupdate.js
replace
url += url.indexOf('&') == -1 ? '?tmpl=component' : '&tmpl=component';
with
url += url.indexOf('&') == -1 ? '?tmpl=component&format=raw' : '&tmpl=component&format=raw';
and copy views\productdetails\view.html.php to views\productdetails\view.raw.php
if will be do the same thing but more faster, without generate, loadnig and parsing useless content.
Title: Re: speedup child product loading
Post by: fale on May 06, 2015, 14:57:57 PM
Hello,

I checked. It does not work in the latest version.  (

and copy views\productdetails\view.html.php to views\productdetails\view.raw.php     -  I do not quite understand these lines.

Child product load slowly. Virtuemart 3 - the slowest store I've ever met.
Title: Re: speedup child product loading
Post by: Milbo on May 06, 2015, 15:02:55 PM
Fale, i have times below 100ms. http://demo.virtuemart.net/product-variants/multi-variant-detail

and VampiRus, your change could break other functions (js). I also wonder what you mean with "useless" content. The whole frame is replaced, did you benchmark your changes?
Title: Re: speedup child product loading
Post by: VampiRUS on May 06, 2015, 16:58:45 PM
for example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
  <base href="http://demo.virtuemart.net/product-variants/multi-variant-11-detail" />
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="keywords" content="virtuemart, vm2, joomla, Joomla" />
  <meta name="title" content="Multi Variant Child" />
  <meta name="description" content="Multi Variant Child Product variants Depended Multivariants" />
  <meta name="generator" content="Joomla! - Open Source Content Management" />
  <title>Product variants : Multi Variant Child</title>
  <link href="/product-variants/multi-variant-detail" rel="canonical" />
  <link href="/templates/vmbeez5/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
  <link rel="stylesheet" href="/components/com_virtuemart/assets/css/vm-ltr-common.css?vmver=8836" type="text/css" />
  <link rel="stylesheet" href="/components/com_virtuemart/assets/css/vm-ltr-site.css?vmver=8836" type="text/css" />
  <link rel="stylesheet" href="/components/com_virtuemart/assets/css/vm-ltr-reviews.css?vmver=8836" type="text/css" />
  <link rel="stylesheet" href="/components/com_virtuemart/assets/css/chosen.css?vmver=8836" type="text/css" />
  <link rel="stylesheet" href="/components/com_virtuemart/assets/css/jquery.fancybox-1.3.4.css?vmver=8836" type="text/css" />
  <script src="/components/com_virtuemart/assets/js/jquery.min.js" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/jquery-migrate.min.js" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/jquery-ui.min.js" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/jquery.ui.autocomplete.html.js" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/jquery.noconflict.js" type="text/javascript" async="async"></script>
  <script src="/components/com_virtuemart/assets/js/vmsite.js?vmver=8836" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/chosen.jquery.min.js?vmver=8836" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/dynupdate.js?vmver=8836" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/vmprices.js?vmver=8836" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/cvfind.js?vmver=8836" type="text/javascript"></script>
  <script src="/components/com_virtuemart/assets/js/fancybox/jquery.fancybox-1.3.4.pack.js?vmver=8836" type="text/javascript" defer="defer"></script>

<link rel="stylesheet" href="/templates/system/css/system.css" type="text/css" />
<link rel="stylesheet" href="/templates/vmbeez5/css/template.css" type="text/css" />
<link rel="stylesheet" href="/templates/vmbeez5/css/position.css" type="text/css" />
<link rel="stylesheet" href="/templates/vmbeez5/css/layout.css" type="text/css" media="screen,projection" />
<link rel="stylesheet" href="/templates/vmbeez5/css/print.css" type="text/css" media="Print" />
<link rel="stylesheet" href="/templates/vmbeez5/css/vmbeez5.css" type="text/css" />

<link rel="stylesheet" href="/templates/vmbeez5/css/general.css" type="text/css" />

<!--[if lte IE 6]>
<link href="/templates/vmbeez5/css/ieonly.css" rel="stylesheet" type="text/css" />
<![endif]-->
</head>
<body class="contentpane">
<div id="all">
<div id="main">

<div id="system-message-container">
</div>

it takes time to convert it in DOM in javascript but not used
I don't now how it can break other js, function get result and use it, no one more use this result or must to use &format=raw
Title: Re: speedup child product loading
Post by: Milbo on May 07, 2015, 08:13:12 AM
So you mean, using the raw function, does not sent the header (opposite of content!). But good to know, yes.

The js handler got added because the js reloaded in the header is "thrown away". So, yes shouldnt make any js problems. But I prefer to find a solution without copying the code. Thanks for the hint
Title: Re: speedup child product loading
Post by: fale on May 07, 2015, 17:18:57 PM

Shop free, little support - a lot of mistakes.

VampiRUS

I did not know what to do to make it faster?
Title: Re: speedup child product loading
Post by: jenkinhill on May 07, 2015, 23:37:10 PM
fale you have already been advised about your slow server speed in http://forum.virtuemart.net/index.php?topic=129784.msg447003#msg447003

Maybe change to a better host?
Title: Re: speedup child product loading
Post by: Studio 42 on May 08, 2015, 15:06:19 PM
Hi,

Quote from: VampiRUS on May 06, 2015, 02:00:15 AM
Hi.
If in
components\com_virtuemart\assets\js\dynupdate.js
replace
url += url.indexOf('&') == -1 ? '?tmpl=component' : '&tmpl=component';
with
url += url.indexOf('&') == -1 ? '?tmpl=component&format=raw' : '&tmpl=component&format=raw';
and copy views\productdetails\view.html.php to views\productdetails\view.raw.php
if will be do the same thing but more faster, without generate, loadnig and parsing useless content.

Sure this is better , because Virtuemart Crop all and only get the main container from the loaded HTML page.
BUt in all '&tmpl=component&format=raw' can be '&format=raw'
But the best solution is to use Json using '&format=json'

BUt you have to know :

for format=raw :
Does not includes Joomla messages(error, warnings ...).
this mean you have to get message and add it before, with a function

for format=json :
YOu have to add Joomla  message in the json response with a function, and add it by a javascript function.

Advantage of json, is that you can provide an object(or array, but this is same for javascript and jQuery) you can then set array of messages, container, javascripts

a sample for json response can be :
{
"id": "45",
"html": "full html child product",
"messages":
[
{"type": "error", "message": "No Access"}
{"type": "warning", "message": "This product have no stock"}
],
"script": "var sku = '123-52-25'"
}



Title: Re: speedup child product loading
Post by: Studio 42 on May 08, 2015, 15:36:04 PM
For the Json response, you can do better thinks :
Adding triggers to update plugins and modules using for eg


$result = $this->loadTemplate($tpl);

if ($result instanceof Exception)
{
  // TODO if tmpl is not found return $result;
}

$json->htm = $result;
// trigger for plugin
$valid = $dispatcher->trigger(('onAjaxProductUpdate',array($product, $json);
// implement a specific fonction to check if modules have to be update
$this->checkmodulesUpdate($product,$json);