plainblack.com
Username Password
search
Bookmark and Share

    

yui scripts loading

User yhkhoe
Date 4/5/2009 11:22 am
Views 1398
Rating 0    Rate [
|
]
Previous · Next
User Message
yhkhoe

I'm working on two Matrix bugs that are probably being caused by some basic yui scripts being loaded more than once.

http://www.webgui.org/bugs/tracker/10033

http://www.webgui.org/bugs/tracker/10080

It looks like the yui scripts that cause problems when they're loaded more than once are Dom, Event and Yahoo. I've encountered this problem in Matrix, Thingy and Survey and i've seen bug reports about other parts of WebGUI that are caused by the same problem.

Sometimes the problems occur in all browsers, sometimes only in IE(7). The error from the browser usually looks something like this:

Error: 'this_events' is a null or not an object

I know that the right place to put the yui script tags is in the perl code, not in any (style)-templates, or a template's head tags field. But that doesn't prevent those templates from containing those script tags anyway.

I'm usually able to fix these problems in some way, sometimes by working around them. But if anyone has a real solution to this problem, i'd like to know it.

Yung



Back to Top
Rate [
|
]
 
 
preaction
I believe a good way to fix this would unfortunately be rather  
intense: Creating a way to attach script, stylesheet, and other stuff  
directly to the template.

This would have some rather nice benefits:

The scripts could be checked against already-loaded scripts and could  
remain unique.
The scripts could be loaded at the end of all other markup, which  
improves render times.
Stylesheets could still be loaded in the HEAD, and would also be unique.
It will be easier for the end-user to add/remove scripts and  
stylesheets in the correct way. No markup required. This helps those  
that want to copy/paste Google Maps code or Facebook code and the like.

Properly done, we could add it any time, but style templates may have  
to be edited to include new template placeholders.

Do you think this would solve the problem?


Back to Top
Rate [
|
]
 
 
patspam
A few more advantages:

YUI scripts could be checked against available aggregate "roll-ups" such as yahoo-dom-event.js and utilitiies.js which combine frequently used components into a single file (less http requests).

If you were serving files off the YUI cdn, you could make use of the "combine all js files" option and have webgui write out a single url along the lines of: http://yui.yahooapis.com/combo?2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&2.7.0/build/animation/animation-min.js

If we ported more of the logic of YUI loader into WebGUI, you could make it possible for templates to simply specify the component names such as "animation", "cookie" mentioned on the corresponding YUI doc page, and then let the webgui figure out required dependencies, load order, etc.. YUI loader allows you to do this for custom modules too, so we could do the same thing with WebGUI's js components.

More info at here. See also the YUI 3.x preview release, which embraces YUI Loader even more.

Patrick

On Mon, Apr 6, 2009 at 5:50 AM, <doug@plainblack.com> wrote:
preaction wrote:

I believe a good way to fix this would unfortunately be rather  
intense: Creating a way to attach script, stylesheet, and other stuff  
directly to the template.

This would have some rather nice benefits:

The scripts could be checked against already-loaded scripts and could  
remain unique.
The scripts could be loaded at the end of all other markup, which  
improves render times.
Stylesheets could still be loaded in the HEAD, and would also be unique.
It will be easier for the end-user to add/remove scripts and  
stylesheets in the correct way. No markup required. This helps those  
that want to copy/paste Google Maps code or Facebook code and the like.

Properly done, we could add it any time, but style templates may have  
to be edited to include new template placeholders.

Do you think this would solve the problem?


http://www.plainblack.com/webgui/dev/discuss/yui-scripts-loading/1


--

Plain Black&#44; makers of WebGUI
http://plainblack.com




Back to Top
Rate [
|
]
 
 
yhkhoe

I think attaching scripts directly to templates would be great and would solve a lot of problems.

And adding the logic of the yui loader would make it very user friendly.

It's not a small change, but i think it would be best in the end.

Yung



Back to Top
Rate [
|
]
 
 
rogier

That's a great idea. Would this mean that the all YUI script and link tags, will be "attached" to a template, instead of being put into the head.tags by the code?

That would give me ... I mean users in general :-) ... a lot of control over the YUI files that are added to a page.

Is someone going to add an RFE for this?

 

Rogier | United Knowledge
www.unitedknowledge.nl · www.webgui-help.nl



Back to Top
Rate [
|
]
 
 
JT

All of this fits right in with what I want to do with WebGUI 8 anyway (for performance), so I'm ok with what was stated here. Unfortunately we don't have any time to get it into the 7.7 schedule. Also, there may be some loading concerns due to content chunking, but that can be worked out as we develop the implementation plan.



Back to Top
Rate [
|
]
 
 
    



© 2012 Plain Black Corporation | All Rights Reserved