dtracers dtracers - 3 months ago 28
jQuery Question

Have $(document).ready wait for an event before firing

For some libraries that use $(document).ready to set up handlers.

They will break if the handler is being applied to custom elements and html imports using the standard polyfills.

With the use of custom elements these events must wait for the WebcomponentsReady event to be fired


The solution (also mentioned here https://github.com/jquery/jquery/issues/2638)

is to use the jQuery holdReady method.

$.holdReady( true );
window.addEventListener("WebcomponentsReady", function() {
  $.holdReady( false );

This should work in all browsers

edit: fixed addEventListener