JS rendering or PHP rendering for re-markup

So, I have a div that repeats several times:

<div class="cmi cm_1_1">
    <span class="cm_img"> 
        <i class="icons">icon_1</i>
    </span> 
    <span class="cm_w">
        something
    </span>                             
    <span class="cm_img"> 
        <i class="icons">icon_2</i>
    </span> 
    <span class="cm_w">
        else
    </span> 
 ... and so on till cm_1_10
</div>

The only thing that will be different is the type and wording of the icon inside. But the markup is identical.

I was thinking about doing js rendering on this using the same markup over and over again (I will just pass the wording through ajax).

or, should I do all this server side (php)?

+4
source share
3 answers

You should probably make a PHP function to render such blocks, unless you plan on rendering this div dynamically after loading the document.

JS , , - , , , . , , js.

: PHP JavaScript HTML-

+2

, - , . . , (, js), .

+1

JS PHP .

JS , DOM / , ( ). , HTML , .

PHP , GZIP PHP, HTML, , , javascript.

, , .

+1

Source: https://habr.com/ru/post/1628451/


All Articles