How to convert JavaScript dynamic data into HTML and render?

227 Views Asked by At

We have developed a website and it uses JavaScript library to query database and display the data in HTML page. When you go to the website, you need to search for something in order to retrieve the data. so by default website doesn't display any data and it needs users to perform action.
The search result data is not visible in HTML view source as it uses JavaScript.
So, the search engines have no visibility as to what our website used for and data used in order to redirect more visitors.

Secondly, I wonder how search bots/engine crawl the websites with non-static content and understand enough about the website to redirect users.

2

There are 2 best solutions below

2
codeboi On

from what i see from your question what you need to do is send requests to your server to query data from your database and show it to you client in real-time.For that i would recommend that you use web sockets(such as socket.io) or AJAX so that you could update your website seamlessly

0
Reality On

From what I have researched, crawlers actually don't read dynamic content. Instead, they use this technique called dynamic rendering.

Dynamic rendering has to do with the server itself. It checks each request and if it determines it to be a bot, then it will send static HTML content to the bot. Otherwise, it will send normal dynamic content to the user.

Also, google and other search engines make use of meta tags. With meta tags you can define a short description of the webpage which will oftentimes be shown in the search results page.


As for question in the title, you would need to send the search information to a server. From there, you would process the data server-side and send the results back to the client where JavaScript would render it based off of the results.

You should use AJAX for this.

Resources: