One-com / livestyle

NodeJS middleware and binary for setting up a webserver that notifies the browser of CSS updates.
BSD 3-Clause "New" or "Revised" License
75 stars 14 forks source link

Inject client before first script tag #53

Closed Munter closed 9 years ago

Munter commented 9 years ago

When using RequireJS in a synchronously loaded script tag in <head /> the requirejs script will expose AMD define before socket.io i loaded. It results in the MISMATCHED ANONYMOUS DEFINE() MODULES error because socket.io's AMD compatibility wrapper calls define itself.

This PR makes the livestyle client be injected before the first script tag if it comes before any of the other matches for </head> or </html>

Ping @papandreou @gustavnikolaj

papandreou commented 9 years ago

Oh gosh, I had managed to completely forget about that hand-rolled state machine.

Anyway, LGTM.

Munter commented 9 years ago

I think there are npm modules out there to solve the same problem for us, but I didn't want to rock the boat to much :)