Expand my Community achievements bar.

How to Enable ES6 Javascript Support for Rendering Dynamic AEM Pages Using HtmlUnit?

Avatar

Level 1

Hi everyone,

 

We have a use case where AEM content pages are dynamically populated with content using ReactJS. To fetch the feully rendered page content(including dynamically inserted elements), we rely on org.htmlunit.webclient by enabling the javascript support in our code. This approach worked well earlier, however, after recent updates to our React codebase, we started encountering issues with ES6 features not being supported by htmlunits current js engine (Rhino).
Specifically we are seeing below error: 

org. htmlunit. ScriptException: identifier is a reserved word: class (https://sample-site:8443/etc.clientlibs/test-project/clientlibs/cms-commons-react.js#241)

This indicates that Rhino engine lacks support for modern JS syntax probably with ES6+ features.

We are exploring alternative solutions that allow us to continue rendering full HTML content in our servlets:

1. Is it possible to integrate a more modern JS engine like GraalVM with htmlunit which might resolve the issue we are facing? If yes, how can we set it up to work with latest version of HtmlUnit.

2. Are there other reliable libraries or strategies available for rendering fully dynamic, JS- heavey pages from AEM?

 

We need a solution that can be used server-side to extract the rendered content. Any guidance for this use case would be highly appreciated! Thank you!


Note- We are on AEM 6.5.19.0
@kautuk_sahni @arunpatidar @kiran5 @lukasz-m @BrianKasingli 

0 Replies