Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does jquery masonry duplicates the imagesLoaded function?

I am new to javascript plugins. So this is my question pertaining to it (with respect to the jQuery masonry).

I noticed the latest masonry.js has imagesLoaded inside it. Then I also noticed that the masonry website suggests users download the imagesLoaded plugin.

  • Q1) Is this a duplication, or do both need to exist in order for this to work?
  • Q2) Do I need to include & reference the separate imagesLoaded.js plugin file in order to use it?

Side Note: I came to this conclusion after noticing that my masonry object loads just fine the FIRST time, but on subsequent loads masonry throws an error when i try to initialize it. Though regardless, the imagesLoaded seems to run just fine WITHOUT including the imagesLoaded plugin file itself.

  • updated *

The bug that I was seeing was due to my not 'deleting' the masonry contents before updated it with new content. So this is not an issue with the updated imagesLoaded.js

like image 370
AlvinfromDiaspar Avatar asked Nov 04 '22 19:11

AlvinfromDiaspar


1 Answers

jQuery Masonry includes an outdated version of the jQuery imagesLoaded plugin v1.1.0.

As of July 30, 2012, the lastest version of jQuery imagesLoaded plugin is v2.0.1 https://github.com/desandro/imagesloaded/blob/master/jquery.imagesloaded.js

You can upgrade jQuery imageloaded from version 1.1.0 to 2.0.1 by including the script after jQuery Masonry.

However, I'm not sure if the upgrade will break anything. But from your question it seems that it does.

Update

jQuery Masonry and jQuery imagesLoaded are different projects by the same person, desandro.

Since jQuery Masonry recommends that you use jQuery imagesLoaded, he make it part of the source so you don't have to import another file.

It easier to import one script instead of two.

When you include the lastest version of jQuery imagesLoad, by importing the seperate script, you're overwriting the old reference to the function call.

The lastest versions of jQuery imagesLoad has cleaner code but both version seem to have the same functionality.

like image 184
Larry Battle Avatar answered Nov 08 '22 15:11

Larry Battle