473,413 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

YUI Libraries

Just a question in general, how do you guys feel about the YUI libraries
from Yahoo? I've just noticed them, used one or two for a couple things,
but I haven't dug too deep.

http://developer.yahoo.com/yui/

~A!
Dec 24 '07 #1
7 1421
On Dec 23, 4:33 pm, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:
Just a question in general, how do you guys feel about the YUI libraries
from Yahoo? I've just noticed them, used one or two for a couple things,
but I haven't dug too deep.

http://developer.yahoo.com/yui/
I think that of the big popular libraries (Dojo, Prototype, jQuery)
the YUI library is the best because I think they've done more things
right than the others. I don't think they have done it all right.

YUI relies on browser sniffing (with navigator.userAgent like all the
big libraries seem to do) which is not necessary except perhaps in
some really rare odd bizarre situation which should probably be
avoided. Sniffing leads to less predictable behavior in untested
browsers. Feature detection is preferred method for dealing with
browser differences and feature detection is many years old now. I
don't think a library can be considered state of the art if it is
using browser sniffing. Yahoo! seems satisfied if the code only works
with only a very small set of new browsers (http://developer.yahoo.com/
yui/articles/gbs/). These browsers do make up the majority of traffic
on the web and Yahoo! is depending on this code but perhaps due to
their size they can afford to sacrifice some visitors. A small company
with a sales site that is barely scraping by may not be able to
sacrifice even one visitor. If your target audience is using cell
phone browsers or some other unusual os/browser combination not in the
graded browser support chart, then perhaps the YUI code wouldn't work
well for your visitors.

YUI has widgets but I have never been able to use a prepackaged widget
in my work. I always need custom widgets and when I wrote a tabbed
pane it was 1/10th the size, had smaller dependency files and did
exactly what I needed including functionality not in the YUI widget. I
don't think the benefit of a general purpose library is in the widgets
but rather in the base libraries like events and ajax.

Even though YUI libraries are broken up into several files, I think
the granularity of the files is too large. There are parts of the
event library and ajax libraries that I've never used but clients
would still need to download them.

The YUI code contains many workarounds for many browser bugs and it
was very educational for me to ready the YUI code.

The YUI team has produced some technical videos about JavaScript that
are well worth watching.

I've had contact with some of the YUI team through the YUI forum over
the last couple years and they are always helpful and friendly.

Peter
Dec 24 '07 #2
My Pet Programmer said the following on 12/23/2007 8:36 PM:

<snip>
Thanks, Peter, I appreciate the response. I don't like the browser
detection, everything I've read has always said feature detect is good,
navigator is bad.
The first two things I check in a library? A search for the word eval
and the word navigator. It is - usually - a pretty good indicator of
whether you need to look any further, depending on what they use it for.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 24 '07 #3
Peter Michaux said:
On Dec 23, 5:36 pm, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:

[snip]
>Their JSON lib is interesting in the way it extends the String prototype
out a bit,

That is not a good idea, in my opinion. I didn't know the YUI team
ever did that and in fact I thought they held the "don't modify what
you don't own" ideal at a premium. After all they namespace like
crazy.
What is it that's irksome about it, beyond the obvious matter of not
knowing what the basic types do in my own apps?

[snip]
http://forkjavascript.org/json/docs
http://dev.forkjavascript.org/trac/b...s/fork/json.js
Ooh, thank you. Clicky-click I go.
~A!
Dec 24 '07 #4
On Dec 23, 9:02 pm, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:
Peter Michaux said:On Dec 23, 5:36 pm, My Pet Programmer <anth...@mypetprogrammer.com>
wrote:
[snip]
Their JSON lib is interesting in the way it extends the String prototype
out a bit,
That is not a good idea, in my opinion. I didn't know the YUI team
ever did that and in fact I thought they held the "don't modify what
you don't own" ideal at a premium. After all they namespace like
crazy.

What is it that's irksome about it, beyond the obvious matter of not
knowing what the basic types do in my own apps?
Augmenting built in prototypes or objects you don't own is playing
with fire.

If your code needs to be robust and you want it to be more likely to
work without modification in weird situations (e.g. mashups or in
legacy pages) then you want to limit your use and dependency on
identifiers in places where others may be playing (e.g. global
identifiers and built-in objects.)

Another problem is if you create at String.prototype.toJSON and then a
standardized version comes along you have to move yours out of the
way. That is maintenance you could have avoided. What can make the
situation worse is if yours doesn't function the same way as the new
standardized version does. Then you can't just add yours if the
standard one doesn't exist.

The only argument I know of in favor of modifying built in objects is
because it makes the programmer feel all warm and fuzzy when they look
at the code. That isn't a good enough reason for me. I've never seen
much difference between writing "toJSON(obj)" and "obj.toJSON()" but
many people are really hung up about it and need to see the second one
in their code.

Peter
Dec 24 '07 #5
Peter Michaux said:
The only argument I know of in favor of modifying built in objects is
because it makes the programmer feel all warm and fuzzy when they look
at the code. That isn't a good enough reason for me. I've never seen
much difference between writing "toJSON(obj)" and "obj.toJSON()" but
many people are really hung up about it and need to see the second one
in their code.

Peter
Thanks for the explanation. I won't mess with the prototypes then. I
thought it was nifty you could do it, but I didn't really see the point,
I've always been an oo guy, and I think I prefer having my functions act
in a same manner. If I really need them encapsulated, I'll drop them in
an object.

Thanks again.

~A!
Dec 24 '07 #6
MB said the following on 1/8/2008 6:02 AM:
Randy Webb wrote:
>I have yet to see an advantage to using eval over dynamic insertion.
The one place I might worry about it would be in IE4 and that falls
way outside the boundaries of "common and modern" browsers.
>>I imagine using eval is faster as it doesn't modify the DOM and the
insertion technique has an implicit eval anyway.

The only windows based browser where they are even close is in IE.
FF2, FF1.5, Opera9 and Safari3, the eval call took almost twice as
long as dynamic script insertion. I used a very simple test case and I
think I actually know why the results are what they are. I am, by no
means, an expert on how eval calls are done inside a browser. From
what I have read, and my own thoughts, it seems that eval is opening
and using a second script engine whereas dynamic insertion is using
the currently running engine. That could be true, it could be patently
false though. It might explain the time differences where that is the
time to load the second JS engine.

IE7 was consistently giving me ~2600 milliseconds for both calls.
FF2.0 eval was ~1900, dynamic insertion was ~750ms.
Opera 9 eval was ~600, dynamic insertion was ~350ms.
Safari3 eval ~300, dynamic insertion was ~150ms.

The test code is at the bottom of this post.

This test is not right.
Indeed.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jan 8 '08 #7
me
My results where:
>
IE7 eval was ~3469ms, dynamic insertion was 15797ms.
Opera9 was ~812ms, dynamic insertion was ~2563ms.
FF2.0 eval was ~2922ms, dynamic insertion was ~4547ms.
Safari3 eval was ~422ms, dynamic insertion was ~703ms.

MB
Interesting- I just tested on Firefox 3.0b2 on Mac and results were in
favor of code insertion:
eval was ~3134 milliseconds.
Dynamic Insertion was ~2161 milliseconds.

I also found that removing the appended script element immediately
reduced IE7's time from ~7364ms to ~3777ms. A decent difference. For
reference, eval took ~1872ms on my PC.
Jan 18 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Cecil Westerhoff | last post by:
I just started with programming under linux with c++. I have programmed for years with Borland C++ Builder. So I have some experience. But I can not find the libraries for intenet stuff. (Ping,...
0
by: Nikki Locke | last post by:
Archive-name: C++-faq/libraries/part1 Comp-lang-c++-archive-name: C++-faq/libraries/part1 Available C++ Libraries FAQ =========================== Introduction ~~~~~~~~~~~~ Dos and don'ts -...
3
by: fabio de francesco | last post by:
Hello, I have a couple of years of experience with C++. I started studying C++ syntax, then I read the B.Stroustrup's book, and eventually I went through the N.Josuttis' book on how to program...
27
by: Matt Kruse | last post by:
Since this topic has come up several times in other threads, I thought I'd make a separate thread and gather opinions from (hopefully) a more varied range of newsgroup participants. What are...
1
by: rajesh_krec | last post by:
Hello Everybody, I'm using Microsoft Visual Studio .NET 2003 (with Vc7 compiler) I have some 15 projects each of which generate a static library when i build the solution in release mode. ...
7
by: Thiru | last post by:
I am writing an application that interacts with Oracle and Teradata. In order to create the executable, I need to link various Oracle and Teradata libraries. I found out that when I link the...
5
by: Jon Kneller | last post by:
I have 2 seperate libraries, compiled to .so files (these are being loaded into a Tcl process). I would like to be able to share data (a linked list) between these libraries - one needs to...
3
by: joseluismarchetti | last post by:
Hello everybody, Although I am sure this is an important question for this group, I am not sure this question belongs to this group and I will be happy to move it to the correct one after you...
23
by: Matt Silberstein | last post by:
Are there any good qualities libraries out there, free or for "reasonable" cost? -- Matt Silberstein Do something today about the Darfur Genocide http://www.beawitness.org
85
by: g | last post by:
Hello, is there any library for C as Boost is for C++? thanks in advance,
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.