davidjbradshaw/iframe-resizer

Error while adding JQuery public methods

apu84 opened this issue · 2 comments

apu84 commented

If jquery is loaded at page footer and some trick is done make ready function to work before jquery is loaded, like described in here http://writing.colin-gourlay.com/safely-using-ready-before-including-jquery iFrameResizer thorws an exception and stops execution.

Uncaught TypeError: Cannot set property 'iFrameResize' of undefined.

Probably can be fixed if use it like,

if (window.jQuery) {$(document).ready(function () {createJQueryPublicMethod(jQuery);});}

Plunker link

Having just read the article, that trick would break just about every jQuery plugin. If you want to do that I'd suggest using requireJS to late load libraries and plugins. Or just load this after jQuery at the foot of your page.

You could also avoid the jQuery 'tax' completely, I've not used it on my last couple of work projects.
http://youmightnotneedjquery.com/

That said this patch will stop it crashing.