Skip to content

Sqwidget Loading sequence

grasuth edited this page Nov 11, 2010 · 2 revisions

This is a quick description of the loading and execution sequence of Sqwidget and widgets in a single page.

Loading and execution happens in the following order:

  1. sqwidget.js loads. It can be loaded asynchronously if required.
  2. Sqwidget object added to the global namespace.
  3. Sqwidget looks for jQuery and loads it from google cdn if not already loaded.
  4. If the global config setting automatic is true, then sqwidget searches for any widgets in the page. These are identified by looking for any <div data-sqwidget="..."></div> elements in the page. Note, if not set to automatic, see below for how to make things start.
  5. Sqwidget reads src: attributes from data-sqwidget attributes in embed divs.
  6. Sqwidget loads widget source files
  7. Style elements extracted from sources and added to the page head
  8. Controller scripts extracted from sources
  9. Templates (sub-templates) extracted from each widget source source
  10. Controller scripts executed -- allowing registration of plugin dependencies using widget.config({});
  11. template dependencies are registerd and loading starts
  12. template controller registration is done (widget.ready, widget.loading, widget.error are registered)
  13. if widget.loading defined, then this is executed, or if there is a template with id='loading' that is loaded into the whole widget When all dependencies are loaded for a particular widget:
  14. widget.ready() is run
Clone this wiki locally