civiccc/replacejs

Move lazy-load functionality into replacejs repo

Closed this issue · 6 comments

I'm about to use replace.js in another one of our projects, and would like the lazy-loading functionality as well.

For now I can just copy the "lazy.js" file to the new project and add the jQuery waypoints plug-in, but it would be nice if this came bundled with replace.js.

There are a few options here:

  • bundle it by default, but degrade in the absence of the waypoint plug-in
  • add it as a separate, optional file, which people can pull in to their asset pipeline manifest if they want it
  • add some kind of "build" rake task so that people can make their own replace.js turning on and off the features they want
  • [insert your brilliant idea here]

Any thoughts on which would be preferable? (assigning to @pguillory to get input)

If we add bits that have dependencies, we should set up the project so that something like Bower can manage the dependencies for us. If we want to bring Waypoints into the mix this way, we would likely need to submit a pull request over there to add support for Bower as well. https://github.com/bower/bower

If we go the build task route, Grunt might be a good option: http://gruntjs.com/

Bundle and degrade sounds good to me. It's not a lot of code. It bloats the interface to replace.js a bit, but if we could pull in this and initializeEach (anything else like that?), we could stop exposing ajaxReplace, which would slim the interface back down quite a bit.

The degraded mode could just immediately lazy-load everything, no waypoints. That would be pretty simple.

It seems premature to get into a build process for replace.js. At the moment it's just a .js file to link -- not a lot to go wrong there.

Sounds good.

I'll take a crack at this (assigning myself), as I need it. Will try to push something up shortly.

Pro.