Hacker News new | ask | show | jobs
by shoebappa 4649 days ago
We're doing something similar with YepNope that is included in Modernizr but it's not as simple as yours. We ran into problems where if there were multiple elements on the page with that dependency (usually a jquery plugin), only one would end up getting initialized. We ended up coming up with a complicated queuing system that queues up all of the initialization requests when it detects that it is in the process of being loaded, and fires for each in the queue after the dependency is loaded. I'm definitely curious to look into your method in terms of multiple items that need to each be initialized and how this is handled with your context require method or require in general.
1 comments

Ah, I've not had to deal with sharing between multiple elements yet - I'm kind of hoping that when I do require.js would give quite a solid base for it. YepNope seems like a good choice for this kind of thing, especially that it can bring in css assets too. Would be awesome to bring in all related assets for a element