You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Paul Stanton <pa...@mapshed.com.au> on 2014/11/19 05:25:46 UTC

[5.3] why is a stack being included when not referenced?

Hi,

I have PageA for which I have created StackA of all the the js it 
includes by the virtue of its self and its components (for production 
efficiency).

I have PageB for which I have not created a stack, and it does not 
import StackA.

However when I request PageB, StackA is being included and as a result I 
have scripting errors.

Why?

It is likely that StackA and PageB share some assets however that 
shouldn't be a reason to include the whole of StackA!

Thanks, p.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 19 Nov 2014 18:21:52 -0200, Paul Stanton <pa...@mapshed.com.au>  
wrote:

> True, visiting PageA and PageB if they both had their own stacks would  
> download shared snippets twice. The trade off between more bytes *IF*  
> the user visits both PageA and PageB or a single resource if they just  
> visit PageA.

Exactly. The better usage is very context-, scenario-specific.

> In my example, the 3 large pages have 3 distinct audiences. Only select  
> people would visit all 3. Therefore it would be great to be able to  
> combine all scripts for each of these.

Build one stack for each page. :) The overlapping between them could be  
refactored to other stacks, used by the page-specific ones.

> I'm not sure which is a better approach generally, but I think the  
> feature of combining scripts is wasted on the current approach.

It's not, at all, when you plan your stacks.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Paul Stanton <pa...@mapshed.com.au>.
True, visiting PageA and PageB if they both had their own stacks would 
download shared snippets twice. The trade off between more bytes *IF* 
the user visits both PageA and PageB or a single resource if they just 
visit PageA.

In my example, the 3 large pages have 3 distinct audiences. Only select 
people would visit all 3. Therefore it would be great to be able to 
combine all scripts for each of these.

I'm not sure which is a better approach generally, but I think the 
feature of combining scripts is wasted on the current approach.

On 20/11/2014 6:57 AM, Thiago H de Paula Figueiredo wrote:
> On Wed, 19 Nov 2014 16:10:53 -0200, Paul Stanton 
> <pa...@mapshed.com.au> wrote:
>
>> Thiago,
>>
>> Tapestry is smart enough to not download JS twice.
>
> I'm not sure you understood my example. It may not download the same 
> JS code twice in the same page, but, considering different pages in 
> the same site, the user browser would download the same JS code twice 
> or more.
>
> Example: x.js and an S stack. PageA includes x.js. PageB includes S. 
> x.js's contents is downloaded twice, beating the whole idea of a 
> stack, JS aggregation and caching. And don't forget that one stack can 
> include other stacks.
>
>> I think this logic is flawed, or at least could be optional, 
>> certainly documented!
>
> I disagree! :) It couldn't be made optional, I think, without creating 
> a lot of confusion.
>
>> Putting scripts within a stack is the only way to have them 
>> aggregated (since 5.2?). This aggregation can yield considerable 
>> performance improvements in the right kind of app. For example, we 
>> have roughly 3 complex and heavily used pages which use around 30 
>> shared components, up to 20 on each page.
>
> So why doesn't your PageA above use the S stack in the example instead 
> of just including x.js? Caching included, in the end, less bytes will 
> be downloaded and processed by the browser.
>
>> its like an opposite of the Java import paradigm - ClassA imports 
>> StringUtils and EJBContainer. ClassB imports StringUtils. Therefore 
>> ClassB must also import EJBContainer ?? no...
>
> I think this metaphor isn't valid at all, because of the huge 
> difference in how the importing is done.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 19 Nov 2014 16:10:53 -0200, Paul Stanton <pa...@mapshed.com.au>  
wrote:

> Thiago,
>
> Tapestry is smart enough to not download JS twice.

I'm not sure you understood my example. It may not download the same JS  
code twice in the same page, but, considering different pages in the same  
site, the user browser would download the same JS code twice or more.

Example: x.js and an S stack. PageA includes x.js. PageB includes S.  
x.js's contents is downloaded twice, beating the whole idea of a stack, JS  
aggregation and caching. And don't forget that one stack can include other  
stacks.

> I think this logic is flawed, or at least could be optional, certainly  
> documented!

I disagree! :) It couldn't be made optional, I think, without creating a  
lot of confusion.

> Putting scripts within a stack is the only way to have them aggregated  
> (since 5.2?). This aggregation can yield considerable performance  
> improvements in the right kind of app. For example, we have roughly 3  
> complex and heavily used pages which use around 30 shared components, up  
> to 20 on each page.

So why doesn't your PageA above use the S stack in the example instead of  
just including x.js? Caching included, in the end, less bytes will be  
downloaded and processed by the browser.

> its like an opposite of the Java import paradigm - ClassA imports  
> StringUtils and EJBContainer. ClassB imports StringUtils. Therefore  
> ClassB must also import EJBContainer ?? no...

I think this metaphor isn't valid at all, because of the huge difference  
in how the importing is done.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Paul Stanton <pa...@mapshed.com.au>.
Thiago,

Tapestry is smart enough to not download JS twice. Your 2nd paragraph 
sounds more likely - someone took the approach that if a resource is in 
a stack, then that resource must require the whole stack.

I think this logic is flawed, or at least could be optional, certainly 
documented!

Putting scripts within a stack is the only way to have them aggregated 
(since 5.2?). This aggregation can yield considerable performance 
improvements in the right kind of app. For example, we have roughly 3 
complex and heavily used pages which use around 30 shared components, up 
to 20 on each page.

In development mode it makes sense to @Import js/css relevant to each 
component, however once stabilised we looked to stacks to help reduce 
the number of resources which need to download before js is processed on 
the client. It was easy to list the resulting set of scripts (css is not 
aggregated by tapestry so ignored) a page ends up using so a stack could 
be made for each of these heavy pages.

great! but not so great when everything else starts breaking...

its like an opposite of the Java import paradigm - ClassA imports 
StringUtils and EJBContainer. ClassB imports StringUtils. Therefore 
ClassB must also import EJBContainer ?? no...

On 19/11/2014 10:30 PM, Thiago H de Paula Figueiredo wrote:
> On Wed, 19 Nov 2014 07:57:19 -0200, Geoff Callender 
> <ge...@gmail.com> wrote:
>
>> I've never seen this but I probably don't have any stacks that 
>> include a resource that I also reference outside of the stack.
>>
>> If it's true then it sounds like a bug.
>
> I'm not sure it is. I guess the reasoning behind this is to not have 
> the user browser download and process the same asset being downloaded 
> from two or more different URLs: one for the asset itself, plus 
> another for each stack in which the asset is included. If there wasn't 
> this behavior and, for example, a component imports one .js file 
> directly and a page using it includes a stack which includes this .js, 
> it would be downloaded and executed twice, probably causing bugs.
>
> This way, I believe we should consider each stack as an unit in which 
> its components don't work unless the other ones are included too. If a 
> given file is used in one stack but can also be referenced directly or 
> in another stack, the stack(s) should be refactored.
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Wed, 19 Nov 2014 07:57:19 -0200, Geoff Callender  
<ge...@gmail.com> wrote:

> I've never seen this but I probably don't have any stacks that include a  
> resource that I also reference outside of the stack.
>
> If it's true then it sounds like a bug.

I'm not sure it is. I guess the reasoning behind this is to not have the  
user browser download and process the same asset being downloaded from two  
or more different URLs: one for the asset itself, plus another for each  
stack in which the asset is included. If there wasn't this behavior and,  
for example, a component imports one .js file directly and a page using it  
includes a stack which includes this .js, it would be downloaded and  
executed twice, probably causing bugs.

This way, I believe we should consider each stack as an unit in which its  
components don't work unless the other ones are included too. If a given  
file is used in one stack but can also be referenced directly or in  
another stack, the stack(s) should be refactored.

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Geoff Callender <ge...@gmail.com>.
I've never seen this but I probably don't have any stacks that include a resource that I also reference outside of the stack.

If it's true then it sounds like a bug.


On 19 Nov 2014, at 3:33 pm, Paul Stanton <pa...@mapshed.com.au> wrote:

> Further digging finds that if StackA includes ResourceA and PageB or any of its components import ResourceA then StackA will be included.
> 
> org.apache.tapestry5.internal.services.ajax.JavaScriptSupportImpl.importJavaScriptLibrary(String) line 240
> 
> I haven't played around with stacks to this degree before however I find this alarming and am going to have to abandon my usage of stacks because of this.
> 
> I am assuming there is no configuration switch to disable the auto-inclusion of stacks unless specifically imported?
> 
> thanks, p.
> 
> On 19/11/2014 3:25 PM, Paul Stanton wrote:
>> Hi,
>> 
>> I have PageA for which I have created StackA of all the the js it includes by the virtue of its self and its components (for production efficiency).
>> 
>> I have PageB for which I have not created a stack, and it does not import StackA.
>> 
>> However when I request PageB, StackA is being included and as a result I have scripting errors.
>> 
>> Why?
>> 
>> It is likely that StackA and PageB share some assets however that shouldn't be a reason to include the whole of StackA!
>> 
>> Thanks, p.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> .
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [5.3] why is a stack being included when not referenced?

Posted by Paul Stanton <pa...@mapshed.com.au>.
Further digging finds that if StackA includes ResourceA and PageB or any 
of its components import ResourceA then StackA will be included.

org.apache.tapestry5.internal.services.ajax.JavaScriptSupportImpl.importJavaScriptLibrary(String) 
line 240

I haven't played around with stacks to this degree before however I find 
this alarming and am going to have to abandon my usage of stacks because 
of this.

I am assuming there is no configuration switch to disable the 
auto-inclusion of stacks unless specifically imported?

thanks, p.

On 19/11/2014 3:25 PM, Paul Stanton wrote:
> Hi,
>
> I have PageA for which I have created StackA of all the the js it 
> includes by the virtue of its self and its components (for production 
> efficiency).
>
> I have PageB for which I have not created a stack, and it does not 
> import StackA.
>
> However when I request PageB, StackA is being included and as a result 
> I have scripting errors.
>
> Why?
>
> It is likely that StackA and PageB share some assets however that 
> shouldn't be a reason to include the whole of StackA!
>
> Thanks, p.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
> .
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org