To answer this question.
Clone this gist, cd, install, and run
git clone https://gist.github.com/c8aef41ee27e5304e94f6a255b048f87.git apply-js-to-html
cd apply-js-to-html
npm install
node example.js
Observe that the output has applied the javascript.