Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Need Changes to BBQ #6

Closed
jeresig opened this issue Sep 13, 2010 · 3 comments
Closed

Need Changes to BBQ #6

jeresig opened this issue Sep 13, 2010 · 3 comments

Comments

@jeresig
Copy link
Contributor

jeresig commented Sep 13, 2010

Right now we're using hashchange and using getters and setters for the state history - unfortunately we have to include the full BBQ for that. Any help in reducing the plugin down to just what we need would be appreciated. You can see what we're using it for in jquery.mobile.js.

@cowboy
Copy link
Contributor

cowboy commented Sep 13, 2010

So, I think that BBQ is already very small at 4kb minified (2kb gzip).

BBQ is basically made of 2 parts, the hashchange event and the param/deparam stuff. The latest hashchange event (v1.3) plugin weighs in at 1.5kb minified (0.8kb gzip), but if the IE6/7-specific code is stripped out, that brings the hashchange event plugin size down to 0.9kb minified (0.5kb gzip).. so 0.6kb (0.3kb) can be saved by removing that stuff.

Since the param/deparam stuff is pretty much the whole point of BBQ, I'm not sure that much savings can be had there. That being said, if you're just going to be storing a full href in the location.hash, you could just use the hashchange event.

A simple feature comparison:

Hashchange event

  • very small: 1.5kb minified (0.8kb gzip)
  • normalize hashchange event cross-browser
  • set/get a simple string hash via location.hash

BBQ

  • larger footprint: 4kb minified (2kb gzip)
  • includes hashchange event
  • set/get a simple string hash
  • set/get hash as an object with properties
  • pushState, getState, removeState helper methods
  • general param/deparam, object merging, fragment and querystring methods

Also note that an upcoming version of BBQ will allow per-hashchange-handler param+value matching, which will work like routes, but work withing standard jQuery event handler bind/trigger patterns.

If 2kb is too big and you still want to handle setting/getting the hash as an object with properties, you might want to take the basic v1.3 hashchange event, strip out the IE6/7 stuff (which is very easy to do), and then write some super-simple non-deep deparam code to parse the hash. Of course, from what I've seen in jQuery.mobile.js, you don't even need the param/deparam stuff at all (but I bet you'll want param/deparam eventually).

@scottjehl
Copy link

seems we might be able to just use hashchange. I'll take a look.

@scottjehl
Copy link

removed dependency on jQuery bbq in this file.

Now we only really need the hashchange plugin, unless plugins like tabs and tree end up needing to track their state via hash params. (Currently, jQuery.tabs.js uses bbq for tracking state under the "tab" parameter.)

For now, this closed by 1e7ed8c

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants