You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Pedro Ayala (JIRA)" <ji...@apache.org> on 2011/06/06 17:38:58 UTC
[jira] [Created] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Optimization load of scripts (javascripts and stylesheets)
----------------------------------------------------------
Key: TAP5-1541
URL: https://issues.apache.org/jira/browse/TAP5-1541
Project: Tapestry 5
Issue Type: Improvement
Components: tapestry-core
Affects Versions: 5.2.4, 5.3
Reporter: Pedro Ayala
Attachments: tapestry-loadscripts-improvement.txt
While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
### Eclipse Workspace Patch 1.0
#P tapestry-core
Index: src/main/resources/org/apache/tapestry5/tapestry.js
===================================================================
--- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
+++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
@@ -2097,28 +2097,47 @@
* elements) contains the given asset URL.
*
* @param collection
- * @param prop
- * property to check ('src' for script, 'href' to style).
* @param assetURL
* complete URL (i.e., with protocol, host and port) to the asset
*/
- contains : function(collection, prop, assetURL) {
+ contains : function(collection, assetURL) {
return $A(collection).any(
function(element) {
- var existing = element[prop];
- if (!existing || existing.blank())
- return false;
-
- var complete = Prototype.Browser.IE ? Tapestry
- .rebuildURL(existing) : existing;
-
- return complete == assetURL;
+ return element == assetURL;
+
});
return false;
},
+
+ /**
+ * Return collection with no blank elements
+ *
+ * @param collection
+ * @param prop
+ * property to check ('src' for script, 'href' to style).
+ */
+ getDocumentCollection : function(collection, prop) {
+ var documentScrips = [];
+ $A(collection).each(
+ function(element) {
+ var existing = element[prop]
+
+ if (!existing || existing.blank())
+ return false;
+
+ var complete = Prototype.Browser.IE ? Tapestry
+ .rebuildURL(existing) : existing;
+
+ documentScrips.push(complete);
+ }
+ );
+
+ return documentScrips;
+ },
+
/**
* Add scripts, as needed, to the document, then waits for them all to load,
* and finally, calls the callback function.
@@ -2131,13 +2150,14 @@
addScripts : function(scripts, callback) {
var scriptsToLoad = [];
+
+ var documentScrips = this.getDocumentCollection(document.scripts, "src");
/* scripts may be null or undefined */
(scripts || []).each(function(s) {
var assetURL = Tapestry.rebuildURL(s);
- if (Tapestry.ScriptManager.contains(document.scripts, "src",
- assetURL))
+ if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
return;
scriptsToLoad.push(assetURL);
@@ -2167,13 +2187,14 @@
return;
var head = $$('head').first();
+
+ var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
$(stylesheets).each(
function(s) {
var assetURL = Tapestry.rebuildURL(s.href);
- if (Tapestry.ScriptManager.contains(document.styleSheets,
- 'href', assetURL))
+ if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
return;
var element = new Element('link', {
type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Attachment: tapestry-loadscripts-improvement.txt
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Description:
While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
### Eclipse Workspace Patch 1.0
#P tapestry-core
Index: src/main/resources/org/apache/tapestry5/tapestry.js
===================================================================
--- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
+++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
@@ -2097,28 +2097,47 @@
* elements) contains the given asset URL.
*
* @param collection
- * @param prop
- * property to check ('src' for script, 'href' to style).
* @param assetURL
* complete URL (i.e., with protocol, host and port) to the asset
*/
- contains : function(collection, prop, assetURL) {
- return $A(collection).any(
+ contains : function(collection, assetURL) {
+ return collection.any(
function(element) {
- var existing = element[prop];
- if (!existing || existing.blank())
- return false;
-
- var complete = Prototype.Browser.IE ? Tapestry
- .rebuildURL(existing) : existing;
-
- return complete == assetURL;
+ return element == assetURL;
+
});
return false;
},
+
+ /**
+ * Return collection with no blank elements
+ *
+ * @param collection
+ * @param prop
+ * property to check ('src' for script, 'href' to style).
+ */
+ getDocumentCollection : function(collection, prop) {
+ var documentScrips = [];
+ $A(collection).each(
+ function(element) {
+ var existing = element[prop]
+
+ if (!existing || existing.blank())
+ return false;
+
+ var complete = Prototype.Browser.IE ? Tapestry
+ .rebuildURL(existing) : existing;
+
+ documentScrips.push(complete);
+ }
+ );
+
+ return $A(documentScrips);
+ },
+
/**
* Add scripts, as needed, to the document, then waits for them all to load,
* and finally, calls the callback function.
@@ -2131,13 +2150,14 @@
addScripts : function(scripts, callback) {
var scriptsToLoad = [];
+
+ var documentScrips = this.getDocumentCollection(document.scripts, "src");
/* scripts may be null or undefined */
(scripts || []).each(function(s) {
var assetURL = Tapestry.rebuildURL(s);
- if (Tapestry.ScriptManager.contains(document.scripts, "src",
- assetURL))
+ if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
return;
scriptsToLoad.push(assetURL);
@@ -2167,13 +2187,14 @@
return;
var head = $$('head').first();
+
+ var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
$(stylesheets).each(
function(s) {
var assetURL = Tapestry.rebuildURL(s.href);
- if (Tapestry.ScriptManager.contains(document.styleSheets,
- 'href', assetURL))
+ if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
return;
var element = new Element('link', {
type : 'text/css',
was:
While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
### Eclipse Workspace Patch 1.0
#P tapestry-core
Index: src/main/resources/org/apache/tapestry5/tapestry.js
===================================================================
--- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
+++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
@@ -2097,28 +2097,47 @@
* elements) contains the given asset URL.
*
* @param collection
- * @param prop
- * property to check ('src' for script, 'href' to style).
* @param assetURL
* complete URL (i.e., with protocol, host and port) to the asset
*/
- contains : function(collection, prop, assetURL) {
+ contains : function(collection, assetURL) {
return $A(collection).any(
function(element) {
- var existing = element[prop];
- if (!existing || existing.blank())
- return false;
-
- var complete = Prototype.Browser.IE ? Tapestry
- .rebuildURL(existing) : existing;
-
- return complete == assetURL;
+ return element == assetURL;
+
});
return false;
},
+
+ /**
+ * Return collection with no blank elements
+ *
+ * @param collection
+ * @param prop
+ * property to check ('src' for script, 'href' to style).
+ */
+ getDocumentCollection : function(collection, prop) {
+ var documentScrips = [];
+ $A(collection).each(
+ function(element) {
+ var existing = element[prop]
+
+ if (!existing || existing.blank())
+ return false;
+
+ var complete = Prototype.Browser.IE ? Tapestry
+ .rebuildURL(existing) : existing;
+
+ documentScrips.push(complete);
+ }
+ );
+
+ return documentScrips;
+ },
+
/**
* Add scripts, as needed, to the document, then waits for them all to load,
* and finally, calls the callback function.
@@ -2131,13 +2150,14 @@
addScripts : function(scripts, callback) {
var scriptsToLoad = [];
+
+ var documentScrips = this.getDocumentCollection(document.scripts, "src");
/* scripts may be null or undefined */
(scripts || []).each(function(s) {
var assetURL = Tapestry.rebuildURL(s);
- if (Tapestry.ScriptManager.contains(document.scripts, "src",
- assetURL))
+ if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
return;
scriptsToLoad.push(assetURL);
@@ -2167,13 +2187,14 @@
return;
var head = $$('head').first();
+
+ var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
$(stylesheets).each(
function(s) {
var assetURL = Tapestry.rebuildURL(s.href);
- if (Tapestry.ScriptManager.contains(document.styleSheets,
- 'href', assetURL))
+ if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
return;
var element = new Element('link', {
type : 'text/css',
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> - return $A(collection).any(
> + contains : function(collection, assetURL) {
> + return collection.any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return $A(documentScrips);
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Closed] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Howard M. Lewis Ship (Closed) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Howard M. Lewis Ship closed TAP5-1541.
--------------------------------------
Resolution: Fixed
Fix Version/s: 5.3
Assignee: Howard M. Lewis Ship
This was fixed as part of TAP5-1708.
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Assignee: Howard M. Lewis Ship
> Fix For: 5.3
>
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> - return $A(collection).any(
> + contains : function(collection, assetURL) {
> + return collection.any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return $A(documentScrips);
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Attachment: tapestry-loadscripts-improvement.txt
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Closed] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Howard M. Lewis Ship (Closed) (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Howard M. Lewis Ship closed TAP5-1541.
--------------------------------------
Resolution: Fixed
Fix Version/s: 5.3
Assignee: Howard M. Lewis Ship
This was fixed as part of TAP5-1708.
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Assignee: Howard M. Lewis Ship
> Fix For: 5.3
>
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> - return $A(collection).any(
> + contains : function(collection, assetURL) {
> + return collection.any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return $A(documentScrips);
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Description:
While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
### Eclipse Workspace Patch 1.0
#P tapestry-core
Index: src/main/resources/org/apache/tapestry5/tapestry.js
===================================================================
--- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
+++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
@@ -2097,28 +2097,47 @@
* elements) contains the given asset URL.
*
* @param collection
- * @param prop
- * property to check ('src' for script, 'href' to style).
* @param assetURL
* complete URL (i.e., with protocol, host and port) to the asset
*/
- contains : function(collection, prop, assetURL) {
- return $A(collection).any(
+ contains : function(collection, assetURL) {
+ return collection.any(
function(element) {
- var existing = element[prop];
- if (!existing || existing.blank())
- return false;
-
- var complete = Prototype.Browser.IE ? Tapestry
- .rebuildURL(existing) : existing;
-
- return complete == assetURL;
+ return element == assetURL;
+
});
return false;
},
+
+ /**
+ * Return collection with no blank elements
+ *
+ * @param collection
+ * @param prop
+ * property to check ('src' for script, 'href' to style).
+ */
+ getDocumentCollection : function(collection, prop) {
+ var documentScrips = [];
+ $A(collection).each(
+ function(element) {
+ var existing = element[prop]
+
+ if (!existing || existing.blank())
+ return false;
+
+ var complete = Prototype.Browser.IE ? Tapestry
+ .rebuildURL(existing) : existing;
+
+ documentScrips.push(complete);
+ }
+ );
+
+ return $A(documentScrips);
+ },
+
/**
* Add scripts, as needed, to the document, then waits for them all to load,
* and finally, calls the callback function.
@@ -2131,13 +2150,14 @@
addScripts : function(scripts, callback) {
var scriptsToLoad = [];
+
+ var documentScrips = this.getDocumentCollection(document.scripts, "src");
/* scripts may be null or undefined */
(scripts || []).each(function(s) {
var assetURL = Tapestry.rebuildURL(s);
- if (Tapestry.ScriptManager.contains(document.scripts, "src",
- assetURL))
+ if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
return;
scriptsToLoad.push(assetURL);
@@ -2167,13 +2187,14 @@
return;
var head = $$('head').first();
+
+ var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
$(stylesheets).each(
function(s) {
var assetURL = Tapestry.rebuildURL(s.href);
- if (Tapestry.ScriptManager.contains(document.styleSheets,
- 'href', assetURL))
+ if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
return;
var element = new Element('link', {
type : 'text/css',
was:
While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
### Eclipse Workspace Patch 1.0
#P tapestry-core
Index: src/main/resources/org/apache/tapestry5/tapestry.js
===================================================================
--- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
+++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
@@ -2097,28 +2097,47 @@
* elements) contains the given asset URL.
*
* @param collection
- * @param prop
- * property to check ('src' for script, 'href' to style).
* @param assetURL
* complete URL (i.e., with protocol, host and port) to the asset
*/
- contains : function(collection, prop, assetURL) {
+ contains : function(collection, assetURL) {
return $A(collection).any(
function(element) {
- var existing = element[prop];
- if (!existing || existing.blank())
- return false;
-
- var complete = Prototype.Browser.IE ? Tapestry
- .rebuildURL(existing) : existing;
-
- return complete == assetURL;
+ return element == assetURL;
+
});
return false;
},
+
+ /**
+ * Return collection with no blank elements
+ *
+ * @param collection
+ * @param prop
+ * property to check ('src' for script, 'href' to style).
+ */
+ getDocumentCollection : function(collection, prop) {
+ var documentScrips = [];
+ $A(collection).each(
+ function(element) {
+ var existing = element[prop]
+
+ if (!existing || existing.blank())
+ return false;
+
+ var complete = Prototype.Browser.IE ? Tapestry
+ .rebuildURL(existing) : existing;
+
+ documentScrips.push(complete);
+ }
+ );
+
+ return documentScrips;
+ },
+
/**
* Add scripts, as needed, to the document, then waits for them all to load,
* and finally, calls the callback function.
@@ -2131,13 +2150,14 @@
addScripts : function(scripts, callback) {
var scriptsToLoad = [];
+
+ var documentScrips = this.getDocumentCollection(document.scripts, "src");
/* scripts may be null or undefined */
(scripts || []).each(function(s) {
var assetURL = Tapestry.rebuildURL(s);
- if (Tapestry.ScriptManager.contains(document.scripts, "src",
- assetURL))
+ if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
return;
scriptsToLoad.push(assetURL);
@@ -2167,13 +2187,14 @@
return;
var head = $$('head').first();
+
+ var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
$(stylesheets).each(
function(s) {
var assetURL = Tapestry.rebuildURL(s.href);
- if (Tapestry.ScriptManager.contains(document.styleSheets,
- 'href', assetURL))
+ if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
return;
var element = new Element('link', {
type : 'text/css',
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> - return $A(collection).any(
> + contains : function(collection, assetURL) {
> + return collection.any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return $A(documentScrips);
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Attachment: tapestry-loadscripts-improvement.txt
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044937#comment-13044937 ]
Pedro Ayala commented on TAP5-1541:
-----------------------------------
Please ignore the first attachment, the second one add a simple optimization.
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Commented] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13044937#comment-13044937 ]
Pedro Ayala commented on TAP5-1541:
-----------------------------------
Please ignore the first attachment, the second one add a simple optimization.
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt, tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
[jira] [Updated] (TAP5-1541) Optimization load of scripts
(javascripts and stylesheets)
Posted by "Pedro Ayala (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/TAP5-1541?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pedro Ayala updated TAP5-1541:
------------------------------
Attachment: tapestry-loadscripts-improvement.txt
> Optimization load of scripts (javascripts and stylesheets)
> ----------------------------------------------------------
>
> Key: TAP5-1541
> URL: https://issues.apache.org/jira/browse/TAP5-1541
> Project: Tapestry 5
> Issue Type: Improvement
> Components: tapestry-core
> Affects Versions: 5.3, 5.2.4
> Reporter: Pedro Ayala
> Attachments: tapestry-loadscripts-improvement.txt
>
>
> While loading the script in the page, we are checking if the list of extra scripts are already included in the document.scripts or document.styleSheets.
> This process involves going through this documents scripts for each script we are loading, and since we are doing some processing each time the client side execution time it seriously affected.
> In order to reduce these process needed for each document script, we are creating a temporary array with the processed info, so we only need to do the check if the scripts are in this array.
> ### Eclipse Workspace Patch 1.0
> #P tapestry-core
> Index: src/main/resources/org/apache/tapestry5/tapestry.js
> ===================================================================
> --- src/main/resources/org/apache/tapestry5/tapestry.js (revision 1132663)
> +++ src/main/resources/org/apache/tapestry5/tapestry.js (working copy)
> @@ -2097,28 +2097,47 @@
> * elements) contains the given asset URL.
> *
> * @param collection
> - * @param prop
> - * property to check ('src' for script, 'href' to style).
> * @param assetURL
> * complete URL (i.e., with protocol, host and port) to the asset
> */
> - contains : function(collection, prop, assetURL) {
> + contains : function(collection, assetURL) {
> return $A(collection).any(
> function(element) {
> - var existing = element[prop];
>
> - if (!existing || existing.blank())
> - return false;
> -
> - var complete = Prototype.Browser.IE ? Tapestry
> - .rebuildURL(existing) : existing;
> -
> - return complete == assetURL;
> + return element == assetURL;
> +
> });
>
> return false;
> },
> +
> + /**
> + * Return collection with no blank elements
> + *
> + * @param collection
> + * @param prop
> + * property to check ('src' for script, 'href' to style).
> + */
> + getDocumentCollection : function(collection, prop) {
> + var documentScrips = [];
>
> + $A(collection).each(
> + function(element) {
> + var existing = element[prop]
> +
> + if (!existing || existing.blank())
> + return false;
> +
> + var complete = Prototype.Browser.IE ? Tapestry
> + .rebuildURL(existing) : existing;
> +
> + documentScrips.push(complete);
> + }
> + );
> +
> + return documentScrips;
> + },
> +
> /**
> * Add scripts, as needed, to the document, then waits for them all to load,
> * and finally, calls the callback function.
> @@ -2131,13 +2150,14 @@
> addScripts : function(scripts, callback) {
>
> var scriptsToLoad = [];
> +
> + var documentScrips = this.getDocumentCollection(document.scripts, "src");
>
> /* scripts may be null or undefined */
> (scripts || []).each(function(s) {
> var assetURL = Tapestry.rebuildURL(s);
>
> - if (Tapestry.ScriptManager.contains(document.scripts, "src",
> - assetURL))
> + if (Tapestry.ScriptManager.contains(documentScrips, assetURL))
> return;
>
> scriptsToLoad.push(assetURL);
> @@ -2167,13 +2187,14 @@
> return;
>
> var head = $$('head').first();
> +
> + var documentStyleSheets = this.getDocumentCollection(document.styleSheets, "href");
>
> $(stylesheets).each(
> function(s) {
> var assetURL = Tapestry.rebuildURL(s.href);
>
> - if (Tapestry.ScriptManager.contains(document.styleSheets,
> - 'href', assetURL))
> + if (Tapestry.ScriptManager.contains(documentStyleSheets, assetURL))
> return;
> var element = new Element('link', {
> type : 'text/css',
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira