Call to RELOAD masonry script before it's initialised

Home Forums Auberge Call to RELOAD masonry script before it's initialised

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #19373

    katw
    Participant

    Call to RELOAD masonry script before it's initialised

    Resolved

    I have a console error for masonry JS used to show posts on home page.

    Console trace:

    cannot call methods on masonry prior to initialization; attempted to call ‘reload’
    masonry.min.js:9:730

    Your scripts-global.js is calling “Reload” too early; before the masonry.min.js has been fully initialised.

    Point in your code:

    /**
    * Posts list
    */
    
    var $postsContainers = $( '.posts' );
    
    $postsContainers
    	.imagesLoaded( function() {
    
    		// Processing
    
    			$postsContainers
    				.masonry( {
    					itemSelector    : '.entry',
    					percentPosition : true,
    					isOriginLeft    : ! $wmIsRtl
    				} );
    
    	} );
    
    setTimeout( function() {
    
    	$postsContainers
    		.masonry( 'reload' ); <--- HERE
    
    }, 600 );
    
    • This topic was modified 2 months, 2 weeks ago by  Oliver Juhas. Reason: Removing obsolete error information
    #19376

    Oliver Juhas
    Keymaster

    Hi katw,

    You experience very strange issues on your website, I can not replicate them in my environment.

    The example code excerpt from theme you have provided actually does start with a check for whether the Masonry script is already loaded. So it definitely should not run prematurely and should not throw any errors.

    Do you use some scripts minification on your website?
    Is your Masonry script being loaded asynchronously (check my previous reply to your other support ticket)?
    Have you tweaked loading order of the scripts in any way (maybe via a plugin)?
    If you disable all the plugins (except Jeptack), do you still experience the issue?
    Can you provide URL to affected website so I can check personally please? (Can you also provide admin access maybe?)

    Best regards,

    Oliver Juhas
    WebMan Design

    #19408

    katw
    Participant

    Oliver this issue has appeared randomly and may be related to network performance issues.

    I saw this message again yesterday and coincidentally got warnings google fonts were not loading and this showed network issues.

    So mark this as resolved.

    #19412

    Oliver Juhas
    Keymaster

    Hi katw,

    Thank you for info. My additional advice would be to load scripts via CDN. That way you can unload your website a bit and so possibly prevent the issue from occurring. Unfortunately, I haven’t found any plugin doing so for Masonry script during my quick search, but if it exists, you are basically looking for something like https://wordpress.org/plugins/use-google-libraries/

    Best regards,

    Oliver Juhas
    WebMan Design

    #19414

    katw
    Participant

    Thanks for the tips. You have really earned a “Most Helpful” badge.

    All the best

    Kat

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.