Message from discussion
A common loader for browser-based toolkits
X-BeenThere: prototype-core@googlegroups.com
Received: by 10.150.112.25 with SMTP id k25ls260716ybc.3.p; Tue, 23 Feb 2010
23:14:09 -0800 (PST)
Received: by 10.151.88.33 with SMTP id q33mr21854475ybl.22.1266995649222;
Tue, 23 Feb 2010 23:14:09 -0800 (PST)
Received: by 10.150.47.17 with SMTP id u17mr21036617ybu.27.1266888621374;
Mon, 22 Feb 2010 17:30:21 -0800 (PST)
Received: by 10.150.47.17 with SMTP id u17mr21036614ybu.27.1266888621343;
Mon, 22 Feb 2010 17:30:21 -0800 (PST)
Return-Path: <jrbu...@gmail.com>
Received: from mail-gx0-f187.google.com (mail-gx0-f187.google.com [209.85.217.187])
by gmr-mx.google.com with ESMTP id 18si335610ywh.13.2010.02.22.17.30.21;
Mon, 22 Feb 2010 17:30:21 -0800 (PST)
Received-SPF: pass (google.com: domain of jrbu...@gmail.com designates 209.85.217.187 as permitted sender) client-ip=209.85.217.187;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jrbu...@gmail.com designates 209.85.217.187 as permitted sender) smtp.mail=jrbu...@gmail.com
Received: by mail-gx0-f187.google.com with SMTP id 3so430866gxk.5
for <prototype-core@googlegroups.com>; Mon, 22 Feb 2010 17:30:21 -0800 (PST)
MIME-Version: 1.0
Received: by 10.150.255.4 with SMTP id c4mr1208ybi.64.1266888621297; Mon, 22
Feb 2010 17:30:21 -0800 (PST)
Date: Mon, 22 Feb 2010 17:30:21 -0800 (PST)
X-IP: 64.46.31.75
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US;
rv:1.9.2) Gecko/20100115 Firefox/3.6,gzip(gfe),gzip(gfe)
Message-ID: <94815c08-277a-4a8e-80bd-42e2e72f42a9@b36g2000pri.googlegroups.com>
Subject: A common loader for browser-based toolkits
From: James Burke <jrbu...@gmail.com>
To: "Prototype: Core" <prototype-core@googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi,
My name is James Burke, and I am usually a Dojo contributor. However,
I have been working on a standalone, non-Dojo script/module loader,
RequireJS, http://requirejs.org.
I want to see if Prototype is interested in using it, and if not the
actual implementation, at least agreeing on the format/API to allow
better interop.
While a Prototype project is capable of using RequireJS without doing
any explicit integration with the Prototype Core, there are some
things that can be done to provide a better experience, mainly making
sure dom:loaded is not fired until any inflight modules/scripts are
loaded. This could be accomplished by modifying
fireContentLoadedEvent() to know if there are require()-ed inflight
modules and to register fireContentLoadedEvent with RequireJS so it
can be called when modules are loaded.
Since RequireJS uses dynamically generated script src="" tags, loading
of scripts/modules is async in nature, and can finish after
DOMContentLoaded.
While smaller projects may not need a script/module loader, larger
ones do, and RequireJS has an optimization tool that can be run a
packaging/deployment time to combine scripts/modules together.
I also believe that browser toolkits should work together to make sure
they have a loader that works well in the browser. Otherwise, as time
goes on, we will be pressed to use a format as described by CommonJS,
which as it stands today does not work well natively in the browser.
If you are interested, I am happy to prep a fork of Prototype that
shows the integration, with unit tests. I have been able to convert
Dojo to RequireJS, and have a fork of jQuery with integration and unit
tests. The jQuery fork assumes optional integration in the JavaScript,
and I would do the same with the Prototype code, only activating the
hooks if require is present.
James