The gadget sends a POST request to edit the page without modifying it. Then, with an AJAX request I GET the page content and replace the #bodyContent with the fetched content. After that, the script fires the "wikipage.content" hook. That's how I make sure that the JS is re-fired to allow, for instance, collapsible stuff to remain collapsible (else, it would be static).
If possible, the lazy loader script needs to load the images when the hook is fired.
Corey will have to confirm, but I believe that the lazy loader script only loads images when they're scrolled into the browser's viewport, so loading them immediately when wikipage.content fires would be inappropriate. Possibly the way to fix this would be for the lazy loader's state to reset instead.
Yeah, the extension only loads images once they're within the browser's viewport (otherwise it wouldn't be truly lazy 😛).
I've never dealt with MediaWiki's mw.hook JS function, @Becasita. Does it trigger extensions the same way Hooks::run(); does? If so, then it shouldn't be too much of an issue to rewrite the script to re-execute when the wikipage.content hook is fired.
Thinking about this a bit more, there's no real reason to require already-loaded images to be reloaded in this case, if there's any way to just pull them from the user's local cache (though if this is done, there should be a way to tell the extension to reload the images regardless, I guess).