ressio / lazy-load-xt

Lazy load XT is a jQuery plugin for images, videos and other media
http://ress.io/lazy-load-xt-jquery/
MIT License
1.36k stars 245 forks source link

Avoid back button problem with Iframes in Firefox #126

Closed darius-heavy closed 2 years ago

darius-heavy commented 2 years ago

Avoid the back button problem with Iframes in Firefox, which causes the need to double click to return to the previous page when Lazyload-xt has already loaded the iframe.

dryabov commented 2 years ago

Could you give more details on how to reproduce the issue? Is iframe navigation stored in the parent's history in Firefox?

darius-heavy commented 2 years ago

It's not shown as a history entry, but seeing how the back button is acting it's obvious that something strange is happening. I have to say that only happens in Firefox. You can repoduce it in the video iframe (youtube, vimeo, ...) demo. http://ressio.github.io/lazy-load-xt/demo/youtube-iframe.htm

1 - Navigate to the demo page 2 - When page is loaded, scroll down. 3 - When the iframes are loaded, you can see how back button works.

dryabov commented 2 years ago

Merged, but I'm thinking about replacing your patch with the following code:

objData = el.contentWindow; /* reuse objData variable */
if (objData) {
    objData.location.replace(src);
} else {
    el.src = src;
}

Being minified, the original code is transformed to something like

"IFRAME"===A.tagName?A.contentWindow.location.replace(B):A.src=B

and the above сode to

(C=A.contentWindow)?C.location.replace(B):A.src=B

that is 15 bytes shorter (I'm trying to keep the minified version as short as possible).

darius-heavy commented 2 years ago

I see it well. Works the same, and is lighter... it's better.