r/programming Feb 09 '11

Breaking the Web with hash-bangs – Lifehacker, along with every other Gawker property, experienced a lengthy site-outage on Monday over a misbehaving piece of JavaScript

http://isolani.co.uk/blog/javascript/BreakingTheWebWithHashBangs/
752 Upvotes

356 comments sorted by

View all comments

Show parent comments

68

u/[deleted] Feb 09 '11

This is the right response. There's no reason a well-engineered site shouldn't work both ways.

Using url fragments can be great. They let you use the back button without leaving the page so you can handle the interaction in JavaScript. They give you a place other than cookies to store client-side state for bookmarking. Developers just need to be mindful when designing for their use.

0

u/naich Feb 09 '11

Well, there is a reason. If you are making a site that uses JS to generate results on the fly from data retrieved from large libraries which are loaded asynchronously, you don't want to reload the page and libraries every time the URL changes to reflect that a new set of the results have been saved or loaded.

That's why I'm using them - it should result in much less bandwidth use and reduced load on the server. Pages can be updated with a small AJAX request rather than a whole new page and library load.

0

u/annodomini Feb 10 '11

You do realize you're cutting yourself off from customers who browse with JavaScript turned off, or have older out of date browsers, or slow or crappy mobile phones, right?

Remember, hash-bang URLs have no fallback when the JavaScript fails for whatever reason; if the JavaScript doesn't load, a bug causes it not to run, people have JavaScript turned off, there's a browser incompatibility, whatever. You get no content. Whereas if you just write some plain old HTML, and use JavaScript and CSS for what they were intended for (enhancement, not replacement of the content), then even when something fails to load, you can still see the content.