TypeError: Illegal invocation at HTMLDocument.document.createEvent only on iOS Safari mobile
Author: philippeauriachCreated Jul 23, 2018Updated Sep 30, 2025
Hi everyone,
I just deployed lazysizes in production for the first time. It is working great, except that my error reporting tool (rollbar dot io), reports a lot of errors only on mobile Safari 10 & 11. Unfortunately I cannot reproduce it on my end.
The stacktrace I get is (I re deployed using the unminified script to know where it comes from) :
TypeError: Illegal invocation
File "(unknown)" line 1 col 35801 in HTMLDocument.document.createEvent
File https://www.fishfriender.com/public/lazysizes/lazysizes.js line 71 col 24 in triggerEvent
File https://www.fishfriender.com/public/lazysizes/lazysizes.js line 526 col 13 in unveilElement
File https://www.fishfriender.com/public/lazysizes/lazysizes.js line 393 col 7 in checkElements
File https://www.fishfriender.com/public/lazysizes/lazysizes.js line 171 col 4 in runScript is included like this : <script src="/public/lazysizes/lazysizes.js" async=""></script>
Does it speak to anyone ?
Source: aFarkas/lazysizes