Skip to content

Can't get it to work with iFrameResizer #501

Open
@daniser

Description

iFrameResizer works perfectly with native lazy loading functionality in supported browsers. But I can't get it to work along with this polyfill. I think it is due to <noscript> tag usage, but I'm not sure.

I've tried following combinations to no avail:

<noscript class="loading-lazy">
    <iframe id="container" src="..." loading="lazy"></iframe>
    <script type="text/javascript">iFrameResize({}, '#container')</script>
</noscript>
<noscript class="loading-lazy">
    <iframe id="container" src="..." loading="lazy"></iframe>
</noscript>
<script type="text/javascript">iFrameResize({}, '#container')</script>

The last one works when contents of the <iframe> is loaded instantly, but not with lazy loading:

<noscript class="loading-lazy">
    <iframe id="container" src="..." loading="lazy" onload="iFrameResize({}, this)"></iframe>
</noscript>

It'd be great if there was a way to register callback function which fires when <iframe> is actually loaded, like this:

loadingAttributePolyfill.prepareElement(document.querySelector('main noscript.loading-lazy'), function () {
    iFrameResize({}, '#container');
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions