dynamic loading of widget APIs

12 views
Skip to first unread message

David Huynh

unread,
May 17, 2009, 7:06:10 PM5/17/09
to simile-...@googlegroups.com
Hi all,

It's been one of the long-standing, advanced issues discussed here: how
to dynamically load various Simile Widget APIs on-the-fly, especially
because there's no way to change the <head> of the page within your web
publishing platform. The challenge is to ensure that the many js files
to be loaded asynchronously are loaded in the right order.

I'm starting to experiment with a solution--here's 2 examples in which
all APIs are loaded only when a button is clicked:


http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loading/fully_dynamic.html

http://trunk.simile-widgets.org/exhibit/examples/test_dynamic_loading/fully_dynamic.html
(ignore the Google Maps "wrong key" alert)

Here's a simpler example in which the APIs are loaded from <script>
inside <body> rather than inside <head>:


http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loading/body_scripts.html

I've tested these on
- Firefox 3, Mac OS X and Windows
- Safari 4, Mac OS X
- IE8
- Chrome

Please let me know if they don't work for you on some particular
browser. (This new dynamic loading support has not been released yet.
What you're seeing are the development versions of the APIs.)

The solution involves generating "compilations", basically a single js
file for each locale that includes all the js code. All compilations
support the same way for specifying a callback.

Thanks,

David

Bruce Robertson

unread,
May 17, 2009, 7:17:54 PM5/17/09
to SIMILE Widgets
All load OK in Camino 1.6.7, OSX 10.5.7

On May 17, 4:06 pm, David Huynh <dfhu...@alum.mit.edu> wrote:
> Hi all,
>
> It's been one of the long-standing, advanced issues discussed here: how
> to dynamically load various Simile Widget APIs on-the-fly, especially
> because there's no way to change the <head> of the page within your web
> publishing platform. The challenge is to ensure that the many js files
> to be loaded asynchronously are loaded in the right order.
>
> I'm starting to experiment with a solution--here's 2 examples in which
> all APIs are loaded only when a button is clicked:
>
> http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...
>
> http://trunk.simile-widgets.org/exhibit/examples/test_dynamic_loading...
> (ignore the Google Maps "wrong key" alert)
>
> Here's a simpler example in which the APIs are loaded from <script>
> inside <body> rather than inside <head>:
>
> http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...

David Huynh

unread,
May 17, 2009, 9:20:45 PM5/17/09
to simile-...@googlegroups.com
Great! Thanks for verifying with Camino!

David

contemplative

unread,
May 18, 2009, 6:17:15 PM5/18/09
to SIMILE Widgets
All 3 load just fine on:

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523
Ubuntu/9.04 (jaunty) Firefox/3.0.10

wjw

On May 17, 6:06 pm, David Huynh <dfhu...@alum.mit.edu> wrote:
> Hi all,
>
> It's been one of the long-standing, advanced issues discussed here: how
> to dynamically load various Simile Widget APIs on-the-fly, especially
> because there's no way to change the <head> of the page within your web
> publishing platform. The challenge is to ensure that the many js files
> to be loaded asynchronously are loaded in the right order.
>
> I'm starting to experiment with a solution--here's 2 examples in which
> all APIs are loaded only when a button is clicked:
>
> http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...
>
> http://trunk.simile-widgets.org/exhibit/examples/test_dynamic_loading...
>     (ignore the Google Maps "wrong key" alert)
>
> Here's a simpler example in which the APIs are loaded from <script>
> inside <body> rather than inside <head>:
>
> http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...

David Huynh

unread,
May 18, 2009, 8:22:55 PM5/18/09
to simile-...@googlegroups.com
contemplative wrote:
> All 3 load just fine on:
>
> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523
> Ubuntu/9.04 (jaunty) Firefox/3.0.10
>
wjw, thanks for testing them out!

David

larr...@yahoo.com

unread,
May 31, 2009, 7:08:40 PM5/31/09
to simile-...@googlegroups.com
Hi David,

Fyi, Yahoo has done a lot of work in this area of dynamic loading of js. See the loader section of the yuo site. They've extended the work in their 3.0 ver.

Larry
Sent via BlackBerry from T-Mobile

-----Original Message-----
From: David Huynh <dfh...@alum.mit.edu>

Date: Sun, 17 May 2009 16:06:10
To: <simile-...@googlegroups.com>
Subject: dynamic loading of widget APIs

David Huynh

unread,
Jun 5, 2009, 12:25:11 PM6/5/09
to simile-...@googlegroups.com
Thanks, Larry. One reason I have been hesitating to use any of these n
frameworks is that our users might actually use one of the other n -1
frameworks, which conflicts with the one we choose. Do you have a sense
of how well YUI plays with other frameworks?

David

John Callahan

unread,
Jun 5, 2009, 3:15:50 PM6/5/09
to simile-...@googlegroups.com

larr...@yahoo.com

unread,
Jun 12, 2009, 10:44:38 AM6/12/09
to simile-...@googlegroups.com

Hi David,

Yui has done a lot of work so it can be loaded at the same time as other frameworks with no conflicts. -- they put everything through the global yui or y object to ensure that the global window namespace is not polluted.

-- I use yiu 2.x lib with timeline (and jquery) and it works fine.

The new 3.x yui additionally includes further work on making the lib more modular so that you do not load more of the lib then you're actually using. -- lowers the initial and final page weights.

I suggest yui due to their specific work in loading js as needed (w/ dependency trees) and your interest in the subject.

If you feel that as-needed loading would be a good feature addition then I suggest that you leverage the yui work rather than re-inventing it. They continue to put time and $$ into the toolkit. Since they use it for powering the main yahoo properties, it is robust, well tested and documented. And they have an excellent community mailing list, including the developers.

Larry



Sent via BlackBerry from T-Mobile

-----Original Message-----
From: David Huynh <dfh...@alum.mit.edu>

Date: Fri, 05 Jun 2009 09:25:11
To: <simile-...@googlegroups.com>
Subject: Re: dynamic loading of widget APIs

steff

unread,
Jul 3, 2009, 7:48:28 AM7/3/09
to SIMILE Widgets
This is interesting stuff since I'm struggling with these problems.
First let me tell you this:

- Example 1 & 3 do not work in: Safari 4.0.1, Firefox 3.5, Opera 9.64
on Mac OS 10.5.7
- Example 2 works perfectly on all 3 just mentioned browsers.

This is strange and I don't have an explanation for this behaviour
(yet). Any recommendations which versions of Ajax and Exhibit should
be included?

Regards,
steff

On 12 Jun., 16:44, larryk...@yahoo.com wrote:
> Hi David,
>
> Yui has done a lot of work so it can be loaded at the same time as other frameworks with no conflicts. -- they put everything through the global yui or y object to ensure that the global window namespace is not polluted.
>
> -- I use yiu 2.x lib with timeline (and jquery) and it works fine.
>
> The new 3.x yui additionally includes further work on making the lib more modular so that you do notloadmore of the lib then you're actually using. -- lowers the initial and final page weights.
>
> I suggest yui due to their specific work in loading js as needed (w/ dependency trees) and  your interest in the subject.
>
> If you feel that as-needed loading would be a good feature addition then I suggest that you leverage the yui work rather than re-inventing it. They continue to put time and $$ into the toolkit. Since they use it for powering the main yahoo properties, it is robust, well tested and documented. And they have an excellent community mailing list, including the developers.
>
> Larry
>
> Sent via BlackBerry from T-Mobile
>
>
>
> -----Original Message-----
> From: David Huynh <dfhu...@alum.mit.edu>
>
> Date: Fri, 05 Jun 2009 09:25:11
> To: <simile-...@googlegroups.com>
> Subject: Re:dynamicloading of widget APIs
>
> Thanks, Larry. One reason I have been hesitating to use any of these n
> frameworks is that our users might actually use one of the other n -1
> frameworks, which conflicts with the one we choose. Do you have a sense
> of how well YUI plays with other frameworks?
>
> David
>
> larryk...@yahoo.com wrote:
> > Hi David,
>
> > Fyi, Yahoo has done a lot of work in this area ofdynamicloading of js. See the loader section of the yuo site. They've extended the work in their 3.0 ver.
>
> > Larry
> > Sent via BlackBerry from T-Mobile
>
> > -----Original Message-----
> > From: David Huynh <dfhu...@alum.mit.edu>
>
> > Date: Sun, 17 May 2009 16:06:10
> > To: <simile-...@googlegroups.com>
> > Subject:dynamicloading of widget APIs
>
> > Hi all,
>
> > It's been one of the long-standing, advanced issues discussed here: how
> > to dynamicallyloadvarious Simile Widget APIs on-the-fly, especially
> > because there's no way to change the <head> of the page within your web
> > publishing platform. The challenge is to ensure that the many js files
> > to be loaded asynchronously are loaded in the right order.
>
> > I'm starting to experiment with a solution--here's 2 examples in which
> > all APIs are loaded only when a button is clicked:
>
> >http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...
>
> >http://trunk.simile-widgets.org/exhibit/examples/test_dynamic_loading...
> >     (ignore the Google Maps "wrong key" alert)
>
> > Here's a simpler example in which the APIs are loaded from <script>
> > inside <body> rather than inside <head>:
>
> >http://trunk.simile-widgets.org/timeline/examples/test_dynamic_loadin...
>
> > I've tested these on
> > - Firefox 3, Mac OS X and Windows
> > - Safari 4, Mac OS X
> > - IE8
> > - Chrome
>
> > Please let me know if they don't work for you on some particular
> > browser. (This newdynamicloading support has not been released yet.
Reply all
Reply to author
Forward
0 new messages