Has anyone used require.js for handling plugin scripts?

I’m starting to refactor the code of my plugin and I’m thinking about using require.js to handle the scripts so that i have a codebase which is more modular and testable. And I’m also planning to load by myself all the required dependencies (jQuery included) so that I’m not hindered by WordPress versions.

Has anyone ever done anything similar?

Related posts

Leave a Reply

2 comments

  1. Yes I’m doing something similar: I’m building a plugin and I’m loading some plugin specific Javascript via Modernizr.load. It’s fairly much Javascript and I don’t want to slow down page load times. I currently don’t intend to load jQuery in this manner though.

    Assume that I did load jQuery via Modernizr. Then what happens if someone activates both your plugin, and my plugin? Might we then load jQuery, twice? (Perhaps we’d load jQuery 1.7.2 once via require.js and once via Modernizr? I don’t know how these script loaders work, internally.)

    I guess that if you load only stuff that you really really know is specific to your plugin only, then you’ll be fine.

    (Danger: This is my first WordPress plugin and I don’t know WordPress or PHP well.)