Hope you are doing well. I designed a elementor widget (slider) using slick carousel. when I am inserting the widget in elementor page, it is working fine when opening the page in browser ([screen shot][1]). The only problem that I have is, the slider not working in elementor editing area ([screen shot][2])

Based on elementor docs I tried to enqueue/register the JS and CSS files related to slider by adding this function:

    function my_plugin_preview_scripts() {

    wp_register_script( 'preview-script-1', plugins_url( 'assets/js/preview-script-1.js', __FILE__ ) );
    wp_register_script( 'preview-script-2', plugins_url( 'assets/js/preview-script-2.js', __FILE__ ), [ 'external-library' ] );
    wp_register_script( 'external-library', plugins_url( 'assets/js/libs/external-library.js', __FILE__ ) );

    wp_enqueue_script( 'preview-script-1' );
    wp_enqueue_script( 'preview-script-2' );
add_action( 'elementor/preview/enqueue_scripts', 'my_plugin_preview_scripts' );

But unfortunately it is not working for me and still I am facing the same issue and I know why it is not working that is because I am not understanding the PHP fully and I dont know where should add this code.

Now I really need your help.

Thanks [1]: https://www.awesomescreenshot.com/image/29151570?key=91342f5d52614a0c21dcfc89c4613d01 [2]: https://www.awesomescreenshot.com/image/29151720?key=2989f8b29e12d64ddeb3e2bd0cf6c862

New contributor
Mohammad Ali Khodadadi is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • You'll need to check with Elementor support on this; the hook you're using (elementor/preview/enqueue_scripts) is one of theirs, not a WordPress core hook.
    – Pat J
    Jun 23 at 16:08


Browse other questions tagged or ask your own question.