Title: How to execute javascript function in custom widget in preview window?
Last modified: April 28, 2022

---

# How to execute javascript function in custom widget in preview window?

 *  Resolved [zeekai](https://wordpress.org/support/users/zeekai/)
 * (@zeekai)
 * [4 years ago](https://wordpress.org/support/topic/how-to-execute-javascript-function-in-custom-widget-in-preview-window/)
 * The widget I created works properly in the frontend to allow the accordion function,
   however in the editor there is no effect even though the script file is loaded
   in the preview iframe when viewed with the browser inspector `elementor-preview-
   iframe`
 * What is the method to execute javascript in preview?
 * The code to load in window
 *     ```
       add_action('elementor/init', function()
       {
         add_action('elementor/preview/enqueue_scripts', function() {
           self::scripts(); // the register and enqueue scripts list
         });
       });
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Elementor Team](https://wordpress.org/support/users/michellei/)
 * (@michellei)
 * [4 years ago](https://wordpress.org/support/topic/how-to-execute-javascript-function-in-custom-widget-in-preview-window/#post-15599612)
 * Hi,
 * You can get assistance for custom code in our GitHub that our developers monitor–
   [https://github.com/elementor/elementor](https://github.com/elementor/elementor)
 *  Thread Starter [zeekai](https://wordpress.org/support/users/zeekai/)
 * (@zeekai)
 * [4 years ago](https://wordpress.org/support/topic/how-to-execute-javascript-function-in-custom-widget-in-preview-window/#post-15600966)
 * Pointing me to **yet another forum** is **not a solution**, especially since 
   the destination is absolutely not specific to my inquiry.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘How to execute javascript function in custom widget in preview window?’
is closed to new replies.

 * ![](https://ps.w.org/elementor/assets/icon-256x256.gif?rev=3444228)
 * [Elementor Website Builder - more than just a page builder](https://wordpress.org/plugins/elementor/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/elementor/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/elementor/)
 * [Active Topics](https://wordpress.org/support/plugin/elementor/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elementor/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elementor/reviews/)

## Tags

 * [development](https://wordpress.org/support/topic-tag/development/)

 * 2 replies
 * 2 participants
 * Last reply from: [zeekai](https://wordpress.org/support/users/zeekai/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/how-to-execute-javascript-function-in-custom-widget-in-preview-window/#post-15600966)
 * Status: resolved