gimite / web-socket-js

HTML5 Web Socket implementation powered by Flash
BSD 3-Clause "New" or "Revised" License
2.73k stars 489 forks source link

Init immediately if document.body is available #107

Closed luciferous closed 12 years ago

luciferous commented 12 years ago

This addresses the issue where document.body is ready before the script is loaded, which means the window "load" event does not fire, and WebSocket never initializes.

This is because web_socket.js relies on the window "load" event for calling WebSocket.__initialize, which embeds the Flash object into document.body. If the document.body is already available, the "load" event does not fire.

This patch introduces checking if document.body is available and if so, immediately calls WebSocket.initialize instead of registering it as a callback.

Possibly related to #101, #62, #93 as IE9 seems especially sensitive to this issue.

gimite commented 12 years ago

Thanks for the patch. But I'll try bottom script method instead first. If it works, I guess it loads a bit earlier.