If you take that approach then every time you want to swap out javascript frameworks you have to touch every single layout or view that might call those methods to adjust them.
- Louis
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.287 / Virus Database: 270.12.21/2102 - Release Date: 05/07/09 05:57:00
Currently there are third-party extensions attempting to install
multiple versions of the same javascript extensions into the header,
and sometimes unnecessarily do so on all served pages. After 300KB of
uncompressed files accumulated in the front page header. Also, the
javascript libraries are being installed into the print preview
window, which causes errors. This became a bit of a problem which I
thought about a great amount this last month.
Perhaps a JDOC-style statement in the header could help manager header
insertions. However, the order of header elements is important and the
availability of a JDOC style statement in the header could lead to
malfunction due to misordered code, and header code is mystical at
best. For example, there is is an erroneous statement in the joomla
library files that META tags should be at the top of the header,
presumably right after BASE. But that stops favicon from working in
IE, which requires the LINK statement to be first in the header, or
the favicon is ignored.
Now I think a new a module would be the best option. Perhaps the
module could be installed multiple times for different Javascript
libraries, and a module implementation would allow selection and
observation of which pages include which libraries in their headers.
That way, a Mootools 1.1 could be resident in one area of a site, and
Mootools 1.2 in another. Otherwise, components will end up installing
both libraries on the same page. The same problem has already occurred
for Jquery and Overlib. There is going to a messy transition while
some components continue to use the old libraries, and a module would
allow site management of such problems.
Also, the module would provide a centralized location for minimized
and zipped versions. My hosting provider does not allow compression of
CSS and JS files on the fly, which is a pretty common problem. So
currently, I rename javascript and css files to have php extensions,
thus they are passed through PHP Gzip compression, and put a PHP
header in them with the right mime type so the client interprets them
correctly, like this:
<?php ob_start ("ob_gzhandler");
header("Content-type: text/javascript");
header("Cache-Control: max-age=2592000");
//header("Cache-Control: must-revalidate");
?> /* <script> */....
Which is useful when developing new scripts. When the script is done,
hosting providers may appreciate a facility in Joomla to store
precompressed versions with the correct header information inserted,
thus reducing cpu load.
Are these good thoughts do you think?
<?php
/**
* @version $Id$
* @package Joomla
* @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
* @license GNU/GPL, see LICENSE.php
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
jimport('joomla.plugin.plugin');
/**
* Joomla! JavaScript Plugin
*
* @package Joomla
* @subpackage System
*/
class plgSystemJavascript extends JPlugin
{
/**
* Constructor
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function plgSystemCache(& $subject, $config)
{
parent::__construct($subject, $config);
}
/**
* Load the custom JHtml helpers folder.
*
* @access public
* @return void
* @since 1.0
*/
function onAfterInitialise()
{
// Only work for site applications.
$application = & JFactory::getApplication();
if($application->isAdmin()) {
return;
}
// Import the JHtml library.
jimport('joomla.html.html');
// Load the custom JHtml helpers folder.
JHtml::addIncludePath(JPATH_ROOT.'/plugins/system/javascript/html');
}
}
class JHTMLBehavior
{
function mootools($debug = null)
{
// Do logic to load JQuery framework.
}
function caption() {
// Do logic to load JQuery version of the caption behavior.
}
function formvalidation() {
// Do logic to load JQuery version of the form validation behavior.
}
Ultimately people should be using the core framework, but as I illustrated earlier... for site implementors there is capacity for not having to "hack" the core to achieve your goals.
- Louis
Are you intending that people like me stop using Joomla?
<?php
$headerScripts = $this->getHeadData();
$headerScripts ['scripts'] = array();
$this->setHeadData($headerScripts);
?>
I appreciate the sentiment, Ian, but I cannot be so lordly as to
dictate what other developers must do with their software. Sometimes
Joomla decides to load Mootools when it's not wanted, the only way to
stop it at the moment is to add conditional directives in PHPor hack
the core.
To summarize some of the responses I have been given to my problems:
* Use another forum instead of Kunena/Fireboard (two weeks work).
* Mandate all developers rewrite their code to use the libraries you
have decided they must use.Don't use plugins that don't work because
they haven't been rewritten (another month's work).
* Entirely ignore the fact that libraries are loaded into RSS feeds
and Print preview windows, which causes problems in RSS readers and
printers (printing and RSS feeds are now disabled).
* Tell my customers on modems to get a faster connection if they want
to use my website. Ignore the 300KB of different libraries and >30
different CSS files my site now needs to load because there is no
unified way to manage it.
Of course, we can agree to disagree. I only speak for the several
hundred developers and >1 million websites on servers which are having
performance problems and content conflicts with the current
implementation and policy. You are free to decide we are all wrong.
No virus found in this incoming message.
Checked by AVG - www.avg.com
Version: 8.5.325 / Virus Database: 270.12.30/2115 - Release Date: 05/14/09 17:54:00
I can't speak for 1.6, but on Joomla 1.5 MooTools loads on all pages,
including print preview and RSS feed windows. This causes JavaScript
errors when other scripts have properly been removed from such pages.
Hi, this just popped into my Twitter and I thought immediately of the JQuery folk around here wanting to get into mootools: http://jqueryvsmootools.com/</somewhat-off-topic>