0

I need to somehow include php inside of a javascript file to get the .json theme path. I have tried this solution in my lottie configuration javascript file:

var electron_path = "<?php echo get_theme_file_uri('js/logo-anim/electron-move.json'); ?>";
var anim = bodymovin.loadAnimation({
   container: document.getElementById('logo-anim'),
   renderer: 'svg',
   loop: true,
   autoplay: true,
   path: electron_path,
})
  • You might find these informative: [Include PHP inside JavaScript (.js) files](https://stackoverflow.com/questions/3241422/include-php-inside-javascript-js-files) and [Executing PHP code inside a .js file](https://stackoverflow.com/questions/23574306/executing-php-code-inside-a-js-file) – showdev Jun 15 '21 at 23:37

0 Answers0