Skip to content

defer loading of the javacripts plugins #14023

Closed

Description

@bassjobsen

The javascripts plugins such as affix and scrollspy use $(window).on('load', function () for initialisation. When defer loading (after window.onload) jquery and / or the plugins, the onload event has already been fired before the code loads.

For this reason i wonder if the plugin can be initialised with something like this:

if (document.readyState !== "loading") init();
else $(window).on('load',init );

Activity

  1. Merg1255 commented on Jul 3, 2014

    @Merg1255

    With the customizer you can combine all the plugins you need from BS. Are you referring to other plugins?..

  2. bassjobsen commented on Jul 3, 2014

    @bassjobsen
    ContributorAuthor

    @Merg1255 no i refer to the BS plugins

  3. hnrch02 commented on Jul 3, 2014

    @hnrch02
    Collaborator
    document.readyState !== "loading"

    wouldn't help at all because document.readyState == 'interactive' is basically DOMContentLoaded, so we should explicitly check for complete, other than that it's a pretty fair request.

  4. bassjobsen commented on Jul 3, 2014

    @bassjobsen
    ContributorAuthor

    @hnrch02, yes i doubt about that. But finally i think the plugins can initialize when the DOM has been loaded and don't have to wait for other resources. That is why i thought document.readyState == 'interactive' should be enough.

    jQuery should be finished loading before loading the plugins, but this dependency check should be done elsewhere i think.

  5. hnrch02 commented on Jul 3, 2014

    @hnrch02
    Collaborator

    Images and other resources that aren't loaded can affect the height of elements, so we could initialize all the plugins when the DOM is ready, but we would need to trigger a refresh for both Affix and ScrollSpy when everything has finished loading. I think it would be sufficient if we just change the current behavior to support post-load auto initialization via the data-api.

  6. mdo commented on Aug 4, 2014

    @mdo
    Member

    Probably something to tackle in v4 if we want to do this at all @fat?

  7. fat commented on Aug 15, 2014

    @fat
    Member

    yeah we can look into it for v4, think it makes sense

  8. mdo commented on Aug 23, 2014

    @mdo
    Member

    Added to the list.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    jsJavaScript or TypeScript sources and plugins

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions