Developer forum

Forum » Templates » HTML vs XSLT
Nuno Aguiar
Reply

Hi,

 

I was under the impression that working with XSLT would be much faster than HTML, because of the If Statements/Defined parsing. I was mistken.

 

I created a blank master page and adapted an eCom Product HTML template with +/-40 If Statements/Defineds, and converted it to XSLT and compared the results. Check the attachment. Color legend:

 - grey - before and after eCom Content - No relevant remarks

 - green - product template processing. XSLT is 10x slower

 - red - differences between HTML and XSLT

 

Despite some variation that occours everytime I loaded the page, HTML stood out. I also noticed that there are differences in getting the content and the way the DataReader performed.

 

Also there were a number of "Starting template.ouput" and "Ending template.output()" repeated several times one after the other when in HTML (I deleted the repeated with 0ms from the excel).

 

Are HTML templates actually adviced for performance issues?

 

Nuno


Replies

 
Morten Bengtson
Reply

Hi Nuno,

 

Performance issues in XSLT templates are most likely caused by either sub-optimal template implementation or that Dynamicweb provides a very large XML document for processing.

  • Could you upload the two templates used in your comparison?
  • What version of Dynamicweb are you using?

Don't rely too much on the template converter provided by Dynamicweb. The converted template will probably work, but you can often improve it significantly by making a few changes here and there.

 

I have experienced some serious issues with XSLT templates when product variants are in use. This is because the XML will contain a lot of data for each variant and the different combinations. Make sure the XML only contains the loops of data that you need (especially on product lists) by specifying the availableloops variable - http://developer.dynamicweb-cms.com/forum.aspx?PID=48&ThreadID=25929#Reply25929

Try calling the page with savetemplatexml=true in the querystring and have a look at the xml file generated in same folder as your xslt template.

 

 
Nuno Aguiar
Reply

Hi Morten,

 

I placed the availableLoops to optimize the performance (I have forgotten about them when converting xslt to html). The comparision is now more equal to HTML, however the processing of the XSLT template itself is almost 10x slower (new version in attachment).

 

I tested with basic simple paragraph templates and the result is the same (also in attachment).

 

I was trying to see after how many if statements/defineds in HTML we should consider changing the template to XSLT, but it seems we need to go overboard to do that. I placed 103 conditional in an HTML paragraph template (although 101 where all the same) with no decrease in performance).

 

I am testing this in 8.2.1.0

 

Nuno

 
Nicolai Høeg Pedersen
Reply

Hi Nuno

 

If you apply the same conditional several times in the same template, it will only be parsed once. So you only get the overhead of a larger file size.

 

//Nicolai

 
Morten Bengtson
Reply

Hi Nuno,

You can speed up your XSLT a bit by changing the way you test for empty string values:

<xsl:if test="ParagraphImage != ''">
	This works, but...
</xsl:if>

<xsl:if test="string(ParagraphImage)">
	... this is about 6 x faster
</xsl:if>

And if you are going to test the same condition 101 times, store it in a variable ;-)

 

When implementing XSLT templates, I recommend that you test the performance of your XSLT against the XML output from DW by using the XSLT Profiler in Visual Studio... or a similar tool. However, you need to split the XSLT into multiple xsl:template elements to be able to locate the performance killers.

 

 
Nuno Aguiar
Reply

Hi Nicolai,

 

Thanks for the info. I will forward that to my team

 

Hi Morten,

 

Thanks for the tips. I will make some more tests. I am trying to produce a best practices manual for our development team and partners and need to provide metrics in XSLT so they know when to turn over from HTML to XSLT

 

Nuno

 

You must be logged in to post in the forum