Skip to content
This repository has been archived by the owner on Jan 10, 2020. It is now read-only.

Commit

Permalink
Prevent duplicate loading of resources with combine option during mul…
Browse files Browse the repository at this point in the history
…tiple calls to the tags, scripts, and/or css methods for a single page. Ref ticket #6 (2cb1b01090c0cdfd96c2c54aa45538ac).
  • Loading branch information
cauld committed Nov 22, 2009
1 parent fbc3e44 commit 0ceada8
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions phploader/loader.php
Expand Up @@ -717,12 +717,10 @@ function getAllDependencies($mname, $loadOptional=false, $completed=array()) {
$key .= YUI_OPTIONAL;
}

/*
if (isset($this->depCache[$key])) {
// $this->log("Using cache " . $mname);
return $this->depCache[$key];
}
*/

$m = $this->modules[$mname];
$mProvides = $this->getProvides($mname);
Expand Down Expand Up @@ -1266,6 +1264,9 @@ function processDependencies($outputType, $moduleType, $skipSort=false, $showLoa
// keep track of all the stuff we loaded so that we don't reload
// scripts if the page makes multiple calls to tags
$this->loaded = array_merge($this->loaded, $sorted);
if ($this->combine === true) {
$this->clearComboLink($outputType);
}

// return the raw data structure
if ($outputType == YUI_DATA) {
Expand Down Expand Up @@ -1466,6 +1467,23 @@ function getComboLink($type) {
return $url;
}

/**
* Clears the combo url of already loaded modules for a specific resource type. Prevents
* duplicate loading of modules if the page makes multiple calls to tags, css, or script.
* @method clearComboLink
* @param {string} type Resource type (i.e.) YUI_JS or YUI_CSS
*/
function clearComboLink($type) {
if ($type == YUI_CSS) {
$this->cssComboLocation = null;
} else if ($type == YUI_JS) {
$this->jsComboLocation = null;
} else {
$this->cssComboLocation = null;
$this->jsComboLocation = null;
}
}

/**
* Adds a module the combo collection for a specified resource type
* @method addToCombo
Expand Down

0 comments on commit 0ceada8

Please sign in to comment.