Jump to content
Great article Rich! I’m a huge fan of your work on Dribble.
Quite often document.write() gets a bad rap. But, to be fair, the issue isn’t using document.write() to write content to the DOM.
The overarching issue is should we use document.write() to load cross-domain scripts (or any scripts for that matter)? I believe we can all agree the answer is no.
Using a Callback approach is novel indeed, but what I really like about it is its unobtrusive foundation and the control it places in the hands of the developer.
Today, widgets like The Deck answer the “what”, “where”, “when” and “how” of injected content. Using a predefined callback puts the “where” and “when” concerns back in the hands of the developer – where they belong!
With a 50/50 split, and the right concerns in the right hands, surely this is a win/win for both parties.
How would a Callback approach compare to loading The Deck’s script asynchronously?
Asynchronous Loading Example:
s.async = true;
s.src = ‘http://widgetjonesdiary.com/punoftheday.js?id=’ + id;
Love the approach! Take Care!