Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion JDocument Registering JS Files for Easy Dependency Management

Received: by 10.224.182.74 with SMTP id cb10mr3363105qab.0.1347052141385;
        Fri, 07 Sep 2012 14:09:01 -0700 (PDT)
X-BeenThere: joomla-dev-platform@googlegroups.com
Received: by 10.224.209.135 with SMTP id gg7ls1506794qab.6.gmail; Fri, 07 Sep
 2012 14:09:00 -0700 (PDT)
Received: by 10.224.27.14 with SMTP id g14mr3358922qac.1.1347052140895;
        Fri, 07 Sep 2012 14:09:00 -0700 (PDT)
Received: by 10.224.86.211 with SMTP id t19msqal;
        Fri, 7 Sep 2012 08:28:26 -0700 (PDT)
Received: by 10.236.74.38 with SMTP id w26mr860975yhd.18.1347031706382;
        Fri, 07 Sep 2012 08:28:26 -0700 (PDT)
Date: Fri, 7 Sep 2012 08:28:26 -0700 (PDT)
From: Donald Gilbert <dilbert4l...@gmail.com>
To: joomla-dev-platform@googlegroups.com
Message-Id: <f71ce517-043a-4fb1-aaf7-50ab3c9427e5@googlegroups.com>
Subject: JDocument Registering JS Files for Easy Dependency Management
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_117_9782716.1347031706023"

------=_Part_117_9782716.1347031706023
Content-Type: multipart/alternative; 
	boundary="----=_Part_118_1406845.1347031706023"

------=_Part_118_1406845.1347031706023
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit

Coming from WordPress, one of the things that I miss is the easy javascript 
dependency management. You could call wp_register_script() and then set 
some dependencies for the script that you registered, and then every time 
you used that script it would also load in the required dependencies. This 
is beyond useful, it is almost a requirement so that extensions don't load 
in multiple versions of the same library from different sources and all 
that.

What I would like to propose and gauge interest for is extending the 
JDocument class with the following methods:
    registerScript($name, $path, $dependencies = null, $overwrite = false);
    unregisterScript($name);


*registerScript:*
@var name    string: lowercase common name for the file. For mootools, it 
would be 'mootools', for jQuery Cycle plugin, it could be 'jquery-cycle', 
you get the idea.
@var path      string: relative or absolute path to the script
@var dependencies    mixed: string or array of named scripts (registered 
through registerScript)
@var overwrite           bool: overwrite the file if it already exists

*unregisterScript:*
@var name    string: name of script to unregister

What is your interest in this?

------=_Part_118_1406845.1347031706023
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Coming from WordPress, one of the things that I miss is the easy javascript=
 dependency management. You could call wp_register_script() and then set so=
me dependencies for the script that you registered, and then every time you=
 used that script it would also load in the required dependencies. This is =
beyond useful, it is almost a requirement so that extensions don't load in =
multiple versions of the same library from different sources and all that.<=
div><br></div><div>What I would like to propose and gauge interest for is e=
xtending the JDocument class with the following methods:</div><div>&nbsp; &=
nbsp; registerScript($name, $path, $dependencies =3D null, $overwrite =3D f=
alse);</div><div>&nbsp; &nbsp; unregisterScript($name);</div><div><br></div=
><div><br></div><div><b>registerScript:</b></div><div>@var name &nbsp; &nbs=
p;string: lowercase common name for the file. For mootools, it would be 'mo=
otools', for jQuery Cycle plugin, it could be 'jquery-cycle', you get the i=
dea.</div><div>@var path &nbsp; &nbsp; &nbsp;string: relative or absolute p=
ath to the script</div><div>@var dependencies &nbsp; &nbsp;mixed: string or=
 array of named scripts (registered through registerScript)</div><div>@var =
overwrite &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bool: overwrite the file if it=
 already exists</div><div><br></div><div><b>unregisterScript:</b></div><div=
>@var name &nbsp; &nbsp;string: name of script to unregister</div><div><br>=
</div><div>What is your interest in this?</div>
------=_Part_118_1406845.1347031706023--

------=_Part_117_9782716.1347031706023--