noelboss / featherlight

Featherlight is a very lightweight jQuery lightbox plugin. It's simple yet flexible and easy to use. Featherlight has minimal css and uses no inline styles, everything is name-spaced, it's completely customizable via config object and offers image, ajax and iframe support out of the box. Featherlights small footprint weights about 4kB – in total.
https://www.noevu.ch/featherlight-js-the-ultra-slim-lightbox/
MIT License
2.08k stars 293 forks source link

Loading Featherlight after using jQuery noconflict #371

Closed jayesbe closed 6 years ago

jayesbe commented 6 years ago

I am using featherlight in an environment where jQuery 1.8 is required. This version is too ancient.. so I load jQuery 3 dynamically.

    var $window = window;
    loadScript('//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js', function() {
            var jQ = $.noConflict(true);
            if (!$window.jQuery) {
                $window['jQuery'] = jQ;
                $window['$'] = jQ;
            }
            loadDeps(jQ);
   });

the loadDeps() method call then loadScript's featherlight.

However.. featherlight is instantiated with jQuery 1.8. Not 3.3.1.

When I inspect the page I can see jQuery 1.8 is loaded.. then I see the jQuery 3.3.1 being loaded.. I then see featherlight 1.7.13 being loaded in that order.

Is what I am trying to do not possible ? does there need to be a change to featherlight to support this requirement ?

marcandre commented 6 years ago

I believe Featherlight will use window.jQuery when loaded. So if you loaded it just before calling $.noConflict above (i.e. when window.jQuery is still 3.3.1), you should have what you want.

jayesbe commented 6 years ago

Thanks @marcandre I'll look into this further.