We help IT Professionals succeed at work.

Javascript + AJAX + Client-Side HTML Template + High performance

Enill asked
i created a public API in PHP.

Now i am in the process of creating a first web client in HTML + JS, this is the first time i am developing a Client Web Application.

That being said, i am looking for advice, library resources, anything that could help with this questioning:

- I need the application to be lightning fast
- I want to completly abstract the Client from the Web Server and created a 100% AJAX application
- I want all html to be created on the client side dynamically, my servers only receive and send JSON data
- For the reason above, i don't want to use MVC pattern, i want to offload my server from any html generation as possible, except for the first load of the web application
- Currently i created about 40% of the Client with what i call 'HTML template'
- HTML Template are basically HTML put and escaped into a string variable as a constant on the javascript side, when i need something specfic, i clone the string and fill the data inside it before appending the html to the web page container
- It currently work and is EXTREMELY FAST since everything is generated on the client side, there is no wait
- All communications to the API is in AJAX

* Storing the HTML templates directly in the javascript code is not very clean even tho it work, and it always require me to escape the html and redeploy every time i change something

* I was thinking of maybe a plugins or framework exist for javascript that could make client-side templating better

* I was also thinking that i could probably generate the template dynamically on the first load from the PHP code by retrieving the HTML file and dropping it into the javascript code

Any help is appreciated,
thanks in advance!
Watch Question

RobOwner (Aidellio)
Most Valuable Expert 2015

You're right about storing the html in the javascript.  As you say it's not clean and if you're not "reusing" the html it's a waste of time.  You are, as you suggest, better off requesting the template from PHP at the beginning and then I would suggest changing the layout based on your json in combination with CSS and javascript.

I'm unaware of a plugin or framework for this and I would imagine it would be quite hard to write given that the end result is so subjective.  Sounds like you've done most of the work towards this anyway.
iGottZFrontend Engineer

Eyal is right. the template engine behind his link has been made by the founder of jquery. its speedy and cross browser compatible.
Top Expert 2007

>>its speedy and cross browser compatible. (sic)

And also no longer being developed. That should tell you something.
RobOwner (Aidellio)
Most Valuable Expert 2015

I agree with Badotz... bad idea to use an unsupported plugin
iGottZFrontend Engineer

then why do you accept it as solution? that doesnt make sense oO

I don't see anyone has sugested better solution.
Top Expert 2007

Not all questions have a solution that you like. Some have no solution at all. Accepting a non-solution as the solution makes no sense.

Why not ask for more advice, or just delete the question?