• rose18

    (@rose18)


    Hi,

    I’m developing a custom widget for Elementor and ran into some issues after updating to the latest version 3.24 +

    In the console, there are these 2 errors (showing up on the front-end of the site ) :

    #1)

    Uncaught TypeError: Cannot read properties of undefined (reading 'handlers')

    at 820 (frontend.min.js?ver=3.24.2:2:4477)

    at __webpack_require__ (webpack-pro.runtime.min.js?ver=3.24.2:2:150)

    at 4906 (frontend.min.js?ver=3.24.2:2:4134)

    at __webpack_require__ (webpack-pro.runtime.min.js?ver=3.24.2:2:150)

    at 3000 (frontend.min.js?ver=3.24.2:2:139)

    at __webpack_require__ (webpack-pro.runtime.min.js?ver=3.24.2:2:150)

    at frontend.min.js?ver=3.24.2:2:24995

    at webpackJsonpCallback (webpack-pro.runtime.min.js?ver=3.24.2:2:5854)

    at frontend.min.js?ver=3.24.2:2:69



    elementor-pro/assets/js/frontend.min.js?ver=3.24.2

    screenshot: https://snipboard.io/4bGuN6.jpg

    #2)

     Uncaught TypeError: Cannot read properties of undefined (reading 'tools')

    at Frontend.initOnReadyComponents (frontend.min.js?ver=3.24.3:2:7393)

    at Frontend.init (frontend.min.js?ver=3.24.3:2:9297)

    at HTMLDocument.<anonymous> (frontend.min.js?ver=3.24.3:2:9523)

    at e (jquery.min.js?ver=3.7.1:2:27028)

    at t (jquery.min.js?ver=3.7.1:2:27330)



    wp-includes/js/jquery/jquery.min.js?ver=3.7.1

    screenshot: https://snipboard.io/HhRKVP.jpg

    I have created a custom elementor widget with Javascript by following these tutorials:
    https://developers.elementor.com/add-javascript-to-elementor-widgets/
    https://developers.elementor.com/building-a-simple-custom-widget-with-javascript/

    The problem occurs when registering a script with the ‘elementor-frontend’ dependency.

    My code:

    wp_register_script( 'custom-slider-swiper-js', plugin_dir_url(dirname( FILE )).'assets/main-slider/public/js/script.js', ['elementor-frontend' ], '1.0.0', true );

    When I removed the ‘elementor-frontend’ dependency, those 2 errors doesn’t show up.

    Also the errors occurs only when I am logged in (when previewing the front-end of the site).
    When I am logged out, the error doesn’t show up on the front-end.

    To avoid these issues/errors I had to roll back to version 3.23.3 for both Elementor + Elementor Pro. Those errors doesn’t show up on version 3.23.3 (and down).

    Can the ‘elementor-frontend’ dependency issue be fixed on the latest version of Elementor?

    Thanks!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi Rose,

    I’m having the same issue, the exact 2 errors with the exact stack trace, and I’m not building any custom widget. My issue is even worse: I’m having a simple page with entering fade animations and simple Headings and Icon Boxes and they are not displayed at all, the page displays as blank, basically the animations that should fade in and display the headings and the icon boxes are not showing up and I get a blank page with just the background images.

    This didn’t happen before the 3.24 release. Thank you for the recommendation, I switched to 3.23.3 and not the page is displayed correctly.

    The team at Elementor should definitively investigate this. I think the issue is in basic Elementor, not in Pro, because I rolled back just Elementor. Now I have Elementor 3.23.3 and Elementor Pro 3.24.1 and all is working well.

    yes definitely a bug – missing images when viewing a page whilst logged in due to uncaught errors:

    Uncaught TypeError: Cannot read properties of undefined (reading ‘handlers’)
    at 820 (frontend.min.js?ver=3.24.3:2:4477)
    at webpack_require (webpack-pro.runtime.min.js?ver=3.24.3:2:150)
    at 4906 (frontend.min.js?ver=3.24.3:2:4134)
    at webpack_require (webpack-pro.runtime.min.js?ver=3.24.3:2:150)
    at 3000 (frontend.min.js?ver=3.24.3:2:139)
    at webpack_require (webpack-pro.runtime.min.js?ver=3.24.3:2:150)
    at frontend.min.js?ver=3.24.3:2:24995
    at webpackJsonpCallback (webpack-pro.runtime.min.js?ver=3.24.3:2:5854)
    at frontend.min.js?ver=3.24.3:2:69


    AND

    jquery.min.js?ver=3.7.1:2 Uncaught TypeError: Cannot read properties of undefined (reading ‘tools’)
    at Frontend.initOnReadyComponents (frontend.min.js?ver=3.24.5:2:7393)
    at Frontend.init (frontend.min.js?ver=3.24.5:2:9297)
    at HTMLDocument. (frontend.min.js?ver=3.24.5:2:9523)
    at e (jquery.min.js?ver=3.7.1:2:27028)
    at t (jquery.min.js?ver=3.7.1:2:27330)

    Confirm – rolled back to 3.23.3 and all OK!

    Ahto

    (@ahtonaris)

    I encountered the same issue on Elementor v3.24.7 (with Pro v3.24.4). It seems that when custom widgets use 'elementor-frontend' as a script dependency, it causes a loading order conflict that results in the error.

    I was able to resolve the issue by delaying the registration of the script, ensuring it loads later in the script order.

    Instead of registering the script directly in the widget constructor like this:
    wp_register_script('handle', '/script.js', ['elementor-frontend'], '1.0.0', true);

    I moved the registration into an action hook with a higher priority:
    add_action( 'wp_enqueue_scripts', function() { wp_register_script('handle', '/script.js', ['elementor-frontend'], '1.0.0', true); }, 999);

    This still changes the loading order of the elementor-frontend script, but not as much and prevents the error.

    Another option that I found was to not specify the dependancy when registering script and then used get_script_depends() to include 'elementor-frontend'.

    • This reply was modified 1 month ago by Ahto. Reason: Additional findings
    Thread Starter rose18

    (@rose18)

    Thank you @ahtonaris ! When you moved the registration into an action hook,

    add_action( 'wp_enqueue_scripts', function() { wp_register_script('handle', '/script.js', ['elementor-frontend'], '1.0.0', true); }, 999);

    did you add that code to your custom widget php file (custom-widget-01.php) or to the main plugin file that registers the widgets?

    When you mentioned the other option, do you mean adding 'elementor-frontend' last (after the custom js ) like below?

    public function get_script_depends() {
    return [ 'custom-js-handle', 'elementor-frontend' ];

    }

    thanks!

    Ahto

    (@ahtonaris)

    @rose18 basically I have setup like this: https://developers.elementor.com/add-javascript-to-elementor-widgets/

    and instead of wp_register_script in the class __construct() method you could put the mentioned action hook.

    I opted to use the other method and I just tested that it does not matter whether you include the 'elementor-frontend' last of first. This just makes sure that the frontend script gets enqueued, even if no other widget on the page requests it. The widget’s script is anyway wrapped into:
    jQuery( window ).on( ‘elementor/frontend/init’, () => { /* class and attachHandler sfuff */ });
    and if the script loads before 'elementor-frontend' on the page it does not really matter, atleast for my usecase.

    Thread Starter rose18

    (@rose18)

    Thank you @ahtonaris ! I have added the action hook in the class __construct() method, and it fixed my issue, thank you so much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.