dimsemenov / Magnific-Popup

Light and responsive lightbox script with focus on performance.
http://dimsemenov.com/plugins/magnific-popup/
MIT License
11.39k stars 3.49k forks source link

When concatenate in a single js file with gulp , $(...).magnificPopup is not a function #836

Open Gonzalo2683 opened 8 years ago

Gonzalo2683 commented 8 years ago

Hello, i have the following problem. I concatenate magnific-popup and other plugins in a single js file, but when run the page the console show me $(...).magnificPopup is not a function, but if i load the magnific-popup in another separate tag script src, this works. What is the problem of concatenate in a single file?

Thanks.

brotkrueml commented 8 years ago

I am using Gulp for concatenation and minifying my JavaScripts into one single file and it works. Magnific Popup is concatented before the first use. Perhaps this is the solution, try it out.

jpcharrier commented 8 years ago

I had a similar issue with CodeKit (yes sadly im a GUI user...) however, codekit was placing my imported scripts (ie base magnificPopup.js) after all my scripts. This could be an issue for you also?

texelate commented 8 years ago

@Gonzalo2683 I tried everything possible with the dist files — even with a shim. I ended up realising that the code it's wrapped in (see Gruntfile.js) makes it incompatible with Gulp and Browserify. Instead concat (either manually or with Gulp) the files in the src/js folder in this order:

core.js inline.js ajax.js image.js zoom.js iframe.js gallery.js retina.js

It will work then. I've packaged the files for the latest release here if you want them: https://github.com/texelate/magnificPopupGulpBrowserify/blob/master/README.md