Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

defer loading of the javacripts plugins #14023

Closed
bassjobsen opened this issue Jul 2, 2014 · 8 comments
Closed

defer loading of the javacripts plugins #14023

bassjobsen opened this issue Jul 2, 2014 · 8 comments
Labels

Comments

@bassjobsen
Copy link
Contributor

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 );
@cvrebert cvrebert added the js label Jul 2, 2014
@Merg1255
Copy link

Merg1255 commented Jul 3, 2014

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

@bassjobsen
Copy link
Contributor Author

@Merg1255 no i refer to the BS plugins

@hnrch02
Copy link
Collaborator

hnrch02 commented Jul 3, 2014

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.

@bassjobsen
Copy link
Contributor Author

@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.

@hnrch02
Copy link
Collaborator

hnrch02 commented Jul 3, 2014

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.

@mdo
Copy link
Member

mdo commented Aug 4, 2014

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

@fat
Copy link
Member

fat commented Aug 15, 2014

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

@mdo mdo closed this as completed Aug 23, 2014
@mdo
Copy link
Member

mdo commented Aug 23, 2014

Added to the list.

@mdo mdo mentioned this issue Aug 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants