Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > On presentational Javascript

Reply
Thread Tools

On presentational Javascript

 
 
Jonathan N. Little
Guest
Posts: n/a
 
      11-20-2008
dorayme wrote:

> All this is quite independent of your other criticism, about bad and/or
> unnecessarily big code.
>


And that is the real killer point. These 'libraries' are big, buggy, and
rely on bad browser sniffing to function. Also to reduce size and|or
obfuscate to 'protect' their source code they are tokenized making
debugging a b*tch!

Roll your own. Create functions that *only* do what you wish and you
will be far more satisfied with the results...

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
Nik Coughlin
Guest
Posts: n/a
 
      11-20-2008
"Jonathan N. Little" <(E-Mail Removed)> wrote in message
news:7b1$49258054$40cba7bf$(E-Mail Removed)...
> dorayme wrote:
>
>> All this is quite independent of your other criticism, about bad and/or
>> unnecessarily big code.
>>

>
> And that is the real killer point. These 'libraries'


See, you're bundling them all together. I felt exactly the same way about
JavaScript libraries until I started looking further into jQuery. So, you
can actually assume that for the most part I agree with you regarding the
other libraries. But all the arguments I've been reading against it just
sound like people who don't know anything about it. I've looked through the
source, not in detail, but enough to feel good about it.

> are big,


Core jQuery is 17KB gzipped - a single medium sized medium quality photo is
bigger than that

> buggy,


Have had no problems with core jQuery, admittedly I haven't used a lot of
the plugins. Of course, it's not bug-free, no piece of non-trivial software
is, including the code that you or I or anyone else writes. But the project
is mature and they have a reputation for fixing bugs quickly.

> and rely on bad browser sniffing to function.


It uses object detection, and internally the sort of thing it uses it for is
stuff like providing an abstracted event model that works across IE and
browsers that support the standard event model, that sort of thing.

> Also to reduce size and|or obfuscate to 'protect' their source code


To reduce size. Given that it's GPL licensed, why would they want to
obfuscate it?

> they are tokenized


The jQuery minimized release isn't tokenized, just comments and whitespace
removed - taking the core from 98KB down to 54KB. Gzipping on the server
reduces this down to 17KB.

> making debugging a b*tch!


You can develop against the non-minimized version with proper whitespace and
comments and then deploy the minimized version on release.

> Roll your own. Create functions that *only* do what you wish and you will
> be far more satisfied with the results...


I always have in the past. The thing is, using jQuery, I can generally do
the same thing in a fraction of the time. My time is too important to hand
craft every little thing, and I don't find any of your objections compelling
enough to think that it's worth spending a day or more writing something I
could do in a couple of hours with jQuery just to avoid having to include a
"mammoth" 17KB of gzipped JavaScript.

Have you looked at it at all? You realise that the core is just a framework
that let's you, as you say, roll your own, just in a more efficient manner?
What you're advocating is like using Java but ignoring its class
libraries... that's all jQuery is, a framework. There are lots of
additional plugins for it, sure, but they're mostly third party. You don't
have to use them, and indeed, I generally don't.

The most useful thing for me is that it lets you select and manipulate the
DOM using CSS3 selectors*, which is extremely powerful. For example, zebra
striping all tables on the page:

$("table tr:nth-child(even)").addClass("striped");

How many lines of JavaScript would that normally take**?

If you're writing a lot of JavaScript then suddenly you find that it doesn't
take many cases like this to make bigger savings than the 17KB you're giving
up.

*these are implemented internally by the library, they don't rely on browser
support
** A List Apart's zebra striping code is ~70 lines

 
Reply With Quote
 
 
 
 
dorayme
Guest
Posts: n/a
 
      11-20-2008
In article <7b1$49258054$40cba7bf$(E-Mail Removed)>,
"Jonathan N. Little" <(E-Mail Removed)> wrote:

> dorayme wrote:
>
> > All this is quite independent of your other criticism, about bad and/or
> > unnecessarily big code.
> >

>
> And that is the real killer point. These 'libraries' are big, buggy, and
> rely on bad browser sniffing to function. Also to reduce size and|or
> obfuscate to 'protect' their source code they are tokenized making
> debugging a b*tch!
>


> Roll your own...


Perhaps this utility is for those less handy with js?

(Anyway, what do I know. I never much feel the need for rounded corners
for elements. I like the honesty of 90 degrees. Roundness has its place
but when it replaces the natural corners in a rectangle, it feels to me
to share the unsatisfactoriness of many artificial replacements.

People stick Holden engines in Jags and Bentleys. They go OK. But a
certain quality and feel to the whole thing in time seems to me to be
slightly distasteful. And we know about silicon body parts for men and
women.

Look, I hate to sound too nazi about this but there is a certain purity
about a rectangle and well... when I become ruler of the world, people
will mess with this purity at their own risk. There will be laws...
Everything, under my rule, will be what it is and not something else).

--
dorayme
 
Reply With Quote
 
pistacchio
Guest
Posts: n/a
 
      11-20-2008
On Nov 19, 11:25*am, gu <(E-Mail Removed)> wrote:
> Hi there. Dispite some people (cit. needed ) claiming there's no
> future for semantic web, when i design a page i try to make it
> semantically meaningful.
>
> I like working on a clean html (a la csszengarden, thought it is not the
> best example of semantic design) and then shape its presentation via CSS.
>
> There are things, as you may well know, that are not easy (or
> impossible) to accomplish via CSS only if you tight to a semantic
> layout. Think at a simple box div ( <div class="box">i'm a box</div> )
> where you want to add rounded corners or some nice extra effect. Most
> solutions are based on extra divs addend within (or around) the main
> div, but, needless to say this is not semantically correct as
> "toprightcorner" does not carry any information that is not merely
> presentational.
>
> My solution (used in a couple of upcoming files) has been using
> "presentational javascript". Taking advantage of jQuery, i write a
> clean, semantic-consistent page, then, with a js script, i add the extra
> stuff (like those said extra-div for every .box div), and i cook
> everything with CSS.
>
> Does this make any sense?


Hi to you all again and thanks for your replies. I think i was not
properly clear in my first post. The discussion about jQuery is
certainly interesting, and so it is the discussion on whether rounding
corners are ok or not. But the main point of my post was not about
that. You can as well replace my sentence about jQuery with "my own
optimized code" or "prototype" and you can also replace "rounded
corners" with "a decorative image of a flower on the right side of the
page" and the core would not change.

I mean, I'm more interested in knowing opinions about the use of
javascript as a tool to accomplish separation of content and
presentation on the client side. What kind of javascript (custom code
or whatever library) and what kind of presentation (rounded corners or
jumping clown GIFs) is beyond the scope of my question.

Thanks
gdp
 
Reply With Quote
 
Nik Coughlin
Guest
Posts: n/a
 
      11-20-2008
> "pistacchio" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > On Nov 19, 11:25 am, gu <(E-Mail Removed)> wrote:
> > Hi there. Dispite some people (cit. needed ) claiming there's no
> > future for semantic web, when i design a page i try to make it
> > semantically meaningful.
> >
> > I like working on a clean html (a la csszengarden, thought it is not the
> > best example of semantic design) and then shape its presentation via
> > CSS.
> >
> > There are things, as you may well know, that are not easy (or
> > impossible) to accomplish via CSS only if you tight to a semantic
> > layout. Think at a simple box div ( <div class="box">i'm a box</div> )
> > where you want to add rounded corners or some nice extra effect. Most
> > solutions are based on extra divs addend within (or around) the main
> > div, but, needless to say this is not semantically correct as
> > "toprightcorner" does not carry any information that is not merely
> > presentational.
> >
> > My solution (used in a couple of upcoming files) has been using
> > "presentational javascript". Taking advantage of jQuery, i write a
> > clean, semantic-consistent page, then, with a js script, i add the extra
> > stuff (like those said extra-div for every .box div), and i cook
> > everything with CSS.
> >
> > Does this make any sense?

>
> Hi to you all again and thanks for your replies. I think i was not
> properly clear in my first post. The discussion about jQuery is
> certainly interesting, and so it is the discussion on whether rounding
> corners are ok or not. But the main point of my post was not about
> that. You can as well replace my sentence about jQuery with "my own
> optimized code" or "prototype" and you can also replace "rounded
> corners" with "a decorative image of a flower on the right side of the
> page" and the core would not change.
>
> I mean, I'm more interested in knowing opinions about the use of
> javascript as a tool to accomplish separation of content and
> presentation on the client side. What kind of javascript (custom code
> or whatever library) and what kind of presentation (rounded corners or
> jumping clown GIFs) is beyond the scope of my question.


Hi,

I asked this same question here in May, here's a link to that discussion:

http://groups.google.com/group/alt.h...4564297ccd195b

 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      11-20-2008
In article
<(E-Mail Removed)>,
pistacchio <(E-Mail Removed)> wrote:

> the main point of my post was not about
> that. You can as well replace my sentence about jQuery with "my own
> optimized code" or "prototype" and you can also replace "rounded
> corners" with "a decorative image of a flower on the right side of the
> page" and the core would not change.
>
> I mean, I'm more interested in knowing opinions about the use of
> javascript as a tool to accomplish separation of content and
> presentation on the client side.


You want an opinion? OK, how about this one. Do clean semantic markup as
best you can. Style as you wish for more than default "appearance".
Still not quite the "look" you want ideally? Fine, then use javascript
for even more extras.

There you go.

--
dorayme
 
Reply With Quote
 
rf
Guest
Posts: n/a
 
      11-21-2008

"Nik Coughlin" <(E-Mail Removed)> wrote in message
news:gg4gjc$354$(E-Mail Removed)...
> "Jonathan N. Little" <(E-Mail Removed)> wrote in message
> news:7b1$49258054$40cba7bf$(E-Mail Removed)...


[jQuery]


> It uses object detection,


So what was that stuff I quoted in another post? Here it is again:

<quote>
// Figure out what browser is being used
jQuery.browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
safari: /webkit/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test(
userAgent )
};
</quote>

That to me looks like totally incomplete browser sniffing.


 
Reply With Quote
 
Nik Coughlin
Guest
Posts: n/a
 
      11-21-2008
"rf" <(E-Mail Removed)> wrote in message
news:5MbVk.16485$(E-Mail Removed)...
>
> "dorayme" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>
>> Nobody claims it works on all browsers.
>>
>> A subset of browsers is usually meant to include a smaller number of
>> browsers than the total (it is not necessarily the case). A "small
>> subset" indicates something like that it is quite the minority of
>> browsers.

>
> Why don't we go to the Authority and see:
>
> http://jquery.com/
>
> Hover over "cross browser". You will see, listed quite clearly (providing
> JQuery supports your browser), exactly four browsers: IE, FF, Safari and
> Opera.
>
> Four browsers is, IMHO, *not* "almost all browsers". Hell, even I have at
> least eight of them installed on my systems and I only dabble in this
> stuff.


You can safely infer that if it works in FF it works in all of the Gecko
browsers seeing as how they all use the same JavaScript engine. Same can be
inferred about Webkit browsers from the fact that Safari is supported... I
see by running the test suite that this is the case for Chrome too, despite
it using a different JavaScript engine to the other Webkit browsers and not
being in the supported list. Chrome fails 1 test of 1270 in the jQuery test
suite, and this is a known bug in Chrome where it doesn't escape >
characters when inserting text nodes.

Given that the market share for IE versions less than 6 is somewhere under
1% (even allowing for how unreliable browser share figures are), and that
the market share for other browsers not using one of the rendering engines
mentioned above is well under 1% (same caveat), I think it's safe to say
"almost all browsers". ~98% is not what I call a "small subset".

> It may well work *by mistake* in other browsers but the author is not
> confident enough to state so.


Hardly by mistake, given my point above.

>> All this is quite independent of your other criticism, about bad and/or
>> unnecessarily big code.

>
> Indeed. And this, pasted directly from the JQuery code, should make you
> very very scared:


Why? What's wrong with it? It's as close as you can get without object
detection, and see my note below about the code base.

> <quote>
> // Figure out what browser is being used
> jQuery.browser = {
> version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1],
> safari: /webkit/.test( userAgent ),
> opera: /opera/.test( userAgent ),
> msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
> mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test(
> userAgent )
> };
> </quote>
>
> Do I see your beloved MAC IE5.5 in there?


Bugger Mac IE5.5

If you audit the code further you'll see that the browser detection stuff is
only used where it's really needed - everything that can be done with object
detection *is* done with object detection.

 
Reply With Quote
 
dorayme
Guest
Posts: n/a
 
      11-21-2008
In article <5MbVk.16485$(E-Mail Removed)>,
"rf" <(E-Mail Removed)> wrote:

> "dorayme" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > In article <qY6Vk.16439$(E-Mail Removed)>,
> > "rf" <(E-Mail Removed)> wrote:
> >>
> >> "Nik Coughlin" <(E-Mail Removed)> wrote in message
> >> news:gg2dpk$c1d$(E-Mail Removed)...
> >> > "rf" <(E-Mail Removed)> wrote in message
> >> > news:1jVUk.16315$(E-Mail Removed)...
> >> >>
> >> >> JQuery is a load of rubbish which only works a small subset of
> >> >> browsers.
> >> >
> >> > Au contraire. It's great, and it works in almost all browsers:
> >>
> >> Almost is not all.

> >
> > Nick was querying your
> >
> > "... only works a small subset of browsers"
> >
> > Nobody claims it works on all browsers.
> >
> > A subset of browsers is usually meant to include a smaller number of
> > browsers than the total (it is not necessarily the case). A "small
> > subset" indicates something like that it is quite the minority of
> > browsers.

>
> Why don't we go to the Authority and see:
>
> http://jquery.com/
>
> Hover over "cross browser". You will see, listed quite clearly (providing
> JQuery supports your browser), exactly four browsers: IE, FF, Safari and
> Opera.
>
> Four browsers is, IMHO, *not* "almost all browsers". Hell, even I have at
> least eight of them installed on my systems and I only dabble in this stuff.
>


No, very well then, but I did have in mind an important factor with my:

"And we could be talking major browsers or simply every browser that is
used at least once in the world in a one year period."

which you snipped.

If the question is about the vast majority of users on top of knowing
that rounded corners not showing will not stop the world, then I think
your criticism of Nik's contentedness with this particular solution is a
little harsh. It is an extreme demand that something that is not
essential should work in all browsers considered simply numerically with
no regard to the practical figures of real usage.

....
>
> Do I see your beloved MAC IE5.5 in there?


That's it, you see. You would not actually catch me dead using this
browser for real. I keep it and mention it to stir up you guys, and that
is the only reason I use and mention it... <g>

--
dorayme
 
Reply With Quote
 
Nik Coughlin
Guest
Posts: n/a
 
      11-21-2008
"dorayme" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> That's it, you see. You would not actually catch me dead using this
> browser for real. I keep it and mention it to stir up you guys, and that
> is the only reason I use and mention it... <g>


I think this is the best argument for using Mac IE5.5 that I've come across.
Had I a Mac I would get my hands on it pronto

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Nathan Sokalski ASP .Net 4 11-08-2007 07:24 AM
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
aop presentational items in Rails? leon breedt Ruby 4 07-27-2004 12:26 PM



Advertisments