To be precise, you cannot use Node.js for a front-end solution, as it runs on the server and not in the browser (think of it like any other server language such as PHP, JSP, etc.).
However, you can create the described solution using jQuery or any other Javascript library, you just need to perform data transfer using Socket.IO. On the server side, you need to handle something using websockets, so the most common way would be to use Node.js, but since you want to use Wordpress, it becomes very complicated because Wordpress is not intended to be used in the way you described, so I'm afraid you will have to write your CMS from scratch in Node.
In addition, the method described by you has a huge drawback. Search robots still cannot analyze and run Javascript, so if all your content was loaded dynamically, it would appear empty for Google and others, so it would be impossible to do this in the search results, which will make your site almost useless.
For MySQL and other modules for Node, you should check the NPM registry and Node modules page .
EDIT After Dwayne explained his decision in the comments, here's how I do it:
- I would use jQuery for the front-end. Linking
document c . On () and setting the selector to 'a' so that every anchor on the web page handler. - The handler parses the
a.href attribute and calculates whether the external link is not to be processed by Javascript, or if it links to the next page, article, etc. You can prevent the default action by calling e.preventDefault() in the handler, which prevents the browser from being redirected to a location. - Then the handler will get the content in JSON by calling
.getJSON() on the article-based URL. The easiest way is to have a specific structure (for example, all URLs like www.domain.com/api), redirect to the Node service using .htaccess to prevent problems with multiple domains. - Node will then see the request, extract the parameters and find out what the user wants. Then connect to the MySQL database using this module (as simple as possible) and return the appropriate content formatted as JSON. Remember to set the Content-Type headers to "application / json".
- jQuery receives a response, calculates the type of request, and updates the content accordingly. Profit.
As you can see, I would not use WebSockets in this case, since you are unlikely to benefit from this. They are mainly intended for small, real-time updates (without huge HTTP headers to reduce bandwidth), which are two-way. This means that the server can also insert data into the browser without asking the browser. In the context of the blog, this is not required, and you will not have too many requests, so the difference in throughput will not be noticeable in any case. If, however, you would like to use it for educational purposes, just replace the getJSON part with SocketIO, I'm not sure if Apache supports proxies. Additional information on the basics of SocketIO here .