2

I'm working on an e-commerce website using Power Reviews to manage product reviews. That service uses javascript to display the reviews on our webpages, which means the content is unlikely to be indexed by search engines. I'm trying to work around this so that the review content can be rendered server side, and therefore indexed.

Their script has two components that we place on our page. First, the script file is placed in the HEAD: http://cdn.powerreviews.com/repos/16238/pr/pwr/engine/js/full.js

Then we call the script where we want it to render HTML on the page, including the ID for the product:

POWERREVIEWS.display.engine(document, { pr_page_id : "product-id-here" });

My current theory is that I could set up a page that runs the javascript, then save the resulting page to a static HTML document. I could then pull that into the product page when it loads. This would need to be automated to update the HTML file for every product a couple of times per day, but there are only a couple dozen products, so I don't expect that to be too overwhelming on the server.

How would I do this? I haven't seen a good way to execute the javascript so I can save the output. Is there a better way to tackle this problem?

Thanks for your help.

1 Answer 1

1

OK... better answer.

The best solution that I could find is to use HtmlUnit http://htmlunit.sourceforge.net/ on the server to execute your html with the javascript and get back the final html that the user would see on the browser.

The library has good support for JavaScript and is headless so you should be able to run it on the server.

You would need to write a small Java wrapper that could accept input via the command line and pass it onto HtmlUnit for processing and then return the result to you. You could then call this wrapper from PHP.

See here: Execute javascript in PHP

Sign up to request clarification or add additional context in comments.

5 Comments

Not sure what you are talking about but there is no way jquery does anything if javascript is not used.
My point was that modern jQuery and jQuery UI use plain HTML objects that are machine readable and searchable so the problem of dynamic only generated JavaScript text is a thing of the past.
Well jQuery doesn't get a chance to be anything more than a text file with most if not all search engines, because they don't process javascript, so that doesn't matter.
In this case, he does not have the content, it is brought in by javascript, so search engines don't ever see it. Not sure what a dialog box has to do with that.
Thanks for pointing me in that direction. Let me do a little digging into it to see if that works for me. I'm not familiar with HtmlUnit at all. Can something like this be run in a shared hosting environment?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.