C
C
Chvanikoff2010-10-12 20:35:30
PHP
Chvanikoff, 2010-10-12 20:35:30

Keep PHP logic or JavaScript?

I’m writing a teaser network and I’m a little tormented by doubts:
the advertising platform hosts a code like <script type="text/javascript" src="someurl.com/site_id/block_id"></script>
which, of course, loads the full JS code to generate a teaser block.
So I'm thinking - to pass the already rendered block to the client (logic in php), or give only the block data in, for example, JSON format, and render it using JS (logic in JS)?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
H
Hotpilot, 2010-10-12
@Hotpilot

For maximum loading speed, take all the rendering logic into a separate static JS script and compress it with gzip, and load the block data in JSON. Static JS will be cached and everything will fly :-) In addition, it will be possible to place several blocks on one page and process them all with the same JS, and not load them for each HTML.

M
MT, 2010-10-13
@MTonly

It makes sense to transfer any tasks to the client side if it:
- saves server resources and/or speeds up page/data loading;
- does not complicate maintenance too much;
- does not compromise security (say, Javascript should not be used to check the correctness of filling out forms without duplication on the server side).

S
Sergey, 2010-10-13
@seriyPS

And the teaser block is not displayed in the Iframe? Ay bad(((((

M
Mithgol, 2010-10-12
@Mithgol

If javascript is already necessary in any case, then why not use it to the maximum, thereby unloading the server from executing code?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question