jyoungblood / smoke.js

framework-agnostic styled alert system for javascript
http://smoke.js.org/
930 stars 107 forks source link

Fixed smoke dialogs availability when there are slow loading images and cleaned tabs mixed with spaces #23

Closed cblage closed 12 years ago

cblage commented 12 years ago

Hey,

I was testing smoke.js on a pre-prodution website and I noticed that it was taking a long time for the dialogs to be available because of a DNS problem with our pre-production CDN. This was because window.onload was being used, and that only fires after the last asset is loaded.

I decided to use a very minimal DOMContentLoaded cross-browser library made by Diego Perini (https://github.com/dperini/ContentLoaded), it's also MIT licensed, so it's compatible) to fix this problem.

This way, smoke dialogs are available as soon as the DOM is ready.

Since I put it in a self-calling lambda, the global namespace won't be polluted, and only window.smoke will be defined.

I also fixed a couple of tabs mixed with spaces indentation issues.

Hope you don't mind the usage of an external library, it's very minimal and doesn't pollute the global namespace.

Carlos

cblage commented 12 years ago

By the way, even tho the top comment says jslint, I actually use jshint, which is a less of a pain in the ass to use, and less strict. You should update the doc to clarify this.

jyoungblood commented 12 years ago

woh cool. i'm not going to merge it just because of the library dependency, but it's interesting food for thought, nonetheless.

cblage commented 12 years ago

Hey,

Yeah, I suppose that depending on an external lib is not great when you want to be library independent.

But without fixing this issue, any calls to smoke js dialogs will be prevented from executing if the website has a single http image request pending.

Short of rewriting the "DOMContentLoaded" behavior from scratch, I don't see a solution that would meet your criteria.

Regardless, I respect your choice of not merging. My radio silence was due to a mix college and my dayjob rendering me without a life for almost a month :P

jyoungblood commented 12 years ago

i know how that goes, man. this time of year, especially, WAY too much stuff going on in general.