lazyload icon indicating copy to clipboard operation
lazyload copied to clipboard

Lazyload breaks the website on Safari for Windows

Open MasterJuan opened this issue 7 years ago • 5 comments

Hello everybody,

Lazyload works very-well on all browsers! However, only on Safari for Windows I noticed, this error and my page doens't load at all!

SyntaxError: Unexpected token 'const' jquery.min.js:2 jQuery.Deferred exception: 'undefined' is not a function (evaluating '$(".lazyload").lazyload()') undefined undefined custom.js:4TypeError: 'undefined' is not a function (evaluating '$(".lazyload").lazyload()')

Why this happens?

MasterJuan avatar Dec 13 '17 15:12 MasterJuan

Yes I too face same issue , could anyone find the reason, please.

hari16haran avatar Jan 05 '18 09:01 hari16haran

In your case the problem seems to be that your browser doesn't support JavaScript ES6 syntax. ("Unexpected token 'const'")

This might be the reason, too: https://caniuse.com/#feat=intersectionobserver Safari doesn't support the IntersectionObserver API.

Try using the v1 version: https://appelsiini.net/projects/lazyload/v1/

tennox avatar Jan 15 '18 16:01 tennox

Polyfills can be used to add missing features to old browsers.

https://github.com/w3c/IntersectionObserver

However development of Safari for Windows has been stopped several years ago. I think the Windows version is 5.x which is from year 2011 so I doubt it is able to run this library. Converting to old JavaScript syntax with Babel might help, but easier might be just disable lazyload with Windows Safari.

tuupola avatar Jan 16 '18 01:01 tuupola

Version 2.0.0-beta.2 I've replaced 3 occurencies of const by var. Works now on Safari 7, 8, 9, 10 on Mac OS 10.09 to 10.11 and still working on Firefox, Chrome and IE Edge and 10.

SuperArnaud avatar Apr 18 '18 15:04 SuperArnaud

I tried that change, but it broke the plugin on Chrome v69

FoxBJK avatar Jun 15 '18 15:06 FoxBJK