In general, the implementation does not require any server side. From the server it is only necessary to load the preliminary content into the necessary elements, and also to save them if necessary. The rest of the server is not necessary.
There was already a recommendation to use iFrame.
Here is my example that I once did for my tasks http://jsfiddle.net/r1o8n298/1/
HTML:
<div> <h1>HTML</h1> <textarea id="html"></textarea> </div> <div> <h1>CSS</h1> <textarea id="css"></textarea> </div> <div> <h1>JavaScript</h1> <textarea id="js"></textarea> </div>
Js:
var widgetTpl = "<!DOCTYPE html>" + "<html>" + "<head>" + "<meta charset=\"utf-8\">" + "<title>Widget</title>" + "<\/head>" + "<body>" + "<\/body>" + "<\/html>"; var outputFrame = document.querySelector("#output"); var outputDoc = outputFrame.contentDocument; var htmlEditor = document.querySelector("#html"); var cssEditor = document.querySelector("#css"); var jsEditor = document.querySelector("#js"); var editors = [htmlEditor, cssEditor, jsEditor]; var prepareSource = function () { var src = widgetTpl; var htmlStr = htmlEditor.value; var cssStr = "<style>" + cssEditor.value + "<\/style>"; var jsStr = "<script>" + jsEditor.value + "<\/script>"; src = src.replace("<\/head>", cssStr + "<\/head>"); src = src.replace("<\/head>", jsStr + "<\/head>"); src = src.replace("<\/body>", htmlStr + "<\/body>"); return src; } var render = function (source) { outputDoc.open(); outputDoc.write(source); outputDoc.close(); } var lastCode = prepareSource(); render(lastCode); editors.forEach(function (editor) { editor.addEventListener("keyup", function () { var source = prepareSource(); if (lastCode !== source) { render(source); lastCode = source; } }); });