joychetry / infinite-scroll-elementor

Infinite Scroll Elementor pulls the next posts automatically when the reader approaches the bottom of the page.
GNU General Public License v3.0
41 stars 9 forks source link

$(...).infiniteScroll is not a function #7

Closed tomslominski closed 2 years ago

tomslominski commented 3 years ago

Hi! Thanks for providing this plugin - it does exactly what I need it to, unfortunately only when I'm logged in... :)

When I'm logged out, I get the following error in Firefox 84.0 and Safari 14.0.1 on macOS and iPadOS:

Screenshot 2021-01-05 at 15 02 46

This happens on a live site I'm working on, as well as on a fresh offline site running on PHP 7.4.1 with WordPress 5.6, Elementor 3.0.15, Elementor Pro 3.0.9 and Infinite Scroll Elementor 2.3.2, and crucially, only when I'm logged out of the site. It works perfectly when I'm logged in as admin. All the relevant scripts seem to be loaded, including the infinite scroll one, so I can't see what the issue is at first glance. Since it's a blank site, I don't think it's an issue with deferred scripts or anything like that, since the live site I tried it on doesn't use that either, and I don't think it's the cache either.

As a sidepoint - why is wp-content/plugins/infinite-scroll-elementor/assets/css/infinite-scroll-elementor.css loaded when it has no useful content?

tomslominski commented 3 years ago

It is about order of scripts after all... As a temporary fix, I made infinite-scroll-js depend on jQuery in my child theme:

add_action( 'elementor/frontend/after_register_scripts', function() {
    global $wp_scripts;

    if( isset( $wp_scripts->registered['infinite-scroll-js'] ) ) {
        array_push( $wp_scripts->registered['infinite-scroll-js']->deps, 'jquery' );
    }
}, 100 );
joychetry commented 3 years ago

Hey @tomslominski thanks for reporting the issue, I have not come across the issue that you have initially stated nor had anybody else complained about it. However, I will check and see if I can generate this error.

And as far as the CSS file goes, I will remove it in the next updates.

mtahca commented 3 years ago

infinite

Similar problem (Astra theme and latest WP) only on chrome. No problem with safari on MacOS. @tomslominski Thanks for tip, its worked.

micksp commented 3 years ago

I have the same issue. I'll try out @tomslominski 's approach. Yes. That worked! Thanks for sharing!

joychetry commented 2 years ago

Fixed in earlier releases.