The default Magento reviews template is generating thousands of DOM elements that are causing slow loads. Especially DT DD tags. Is there any way to clean the code? The only one I can see is removing the SPAN element after "review by".

  <?php foreach ($_items as $_review):?>
            <a href="<?php echo $this->getReviewUrl($_review->getId()) ?>"><?php echo $this->escapeHtml($_review->getTitle()) ?></a> <?php echo $this->__('Review by <span>%s</span>', $this->escapeHtml($_review->getNickname())) ?>
            <?php $_votes = $_review->getRatingVotes(); ?>
            <?php if (count($_votes)): ?>
            <table class="ratings-table">
                <col width="1" />
                <col />
                    <?php foreach ($_votes as $_vote): ?>
                        <th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
                            <div class="rating-box">
                                <div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
                    <?php endforeach; ?>
            <?php endif; ?>
            <?php echo nl2br($this->escapeHtml($_review->getDetail())) ?>
            <small class="date"><?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?></small>
    <?php endforeach; ?>


I have removed that SPAN and SMALL attributes, which reduced DOM elements from 5k to 4700, but that is still way too much.

  • I think this one would completely depend upon what you can do with HTML/CSS combination. Magento itself is offering just a skeleton to display a review, and if you are concerned with the DOM elements in this template, you can completely rewrite it with the minimal of elements that give you the similar view. – Prateek May 1 '18 at 17:26
  • this is what i am asking? – Vygantas May 1 '18 at 18:02
  • I know, but afraid can't offer any actual help, as you are the one who gets to decide what HTML/CSS changes would sit well with your current design. No one else can tell you that, at-least not without spending some time on your actual front-end design, and then, it would be better for stackoverflow.com , than here, – Prateek May 1 '18 at 18:06
  • You could eliminate the table completely, just leaving the content of the link and <div class="rating-box">. That would, however, mean that you have to completely start over with styling, adding CSS to make it look the way you want. – mtr.web May 1 '18 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.