library of practical JavaScript examples

M

Manne

I'm looking for a library of practical JavaScript examples. Can you
recommend any?
Thanks for your time.
 
K

Kevin Darling

Manne said:
I'm looking for a library of practical JavaScript examples. Can you
recommend any?

Depends. Are you experienced or just starting out with the language.
If the latter, try looking though the examples at the bottom of this
page:

http://irt.org/script/script.htm

Otherwise, you'll need to be more specific as to what kind of examples
you're looking for... some sites specialize.

Kev
 
D

Dr John Stockton

JRS: In article <[email protected]>
, dated Tue, 18 Jul 2006 09:24:20 remote, seen in
news:comp.lang.javascript said:
I'm looking for a library of practical JavaScript examples. Can you
recommend any?

No.

Be warned : many such are old and contain amateurish coding.

Be particularly wary of those which allow almost anyone to contribute
almost anything without applying quality control.

For example, one such site contains code obviously copied (without
permission) from my site; but it has been so carelessly copied as to be
of little use as it stands.

When using libraries, remember that the whole of a page, and of the
include files that it uses, must in general be transmitted to the
reader, who may be on a radio or dial-up link. Therefore, use the sort
of library that allows you substantially to select, as an author, only
code which will be executed, and avoid the sort which provides only vast
multi-purpose chunks.

Watch out also for those who code for one specific version of one
browser.
 
M

Matt Kruse

Dr said:
Therefore, use the
sort of library that allows you substantially to select, as an
author, only code which will be executed, and avoid the sort which
provides only vast multi-purpose chunks.

Two points:

1) In many cases, you can't determine which code will be executed. You can
often only determine which code can _possibly_ be executed.

2) If 5 different pages each use 50% of a 10k "multi-purpose chunk" of code,
it is better to deliver the 10k chunk once and let the browser cache it (10k
total download) vs. delivering 5k of page-specific code 5 times (25k total
downloaded).

I favor writing smaller "multi-purpose chunks" of compacted code, and having
the page select which ones it needs to include. Then you can properly
benefit from caching, include only the small libs which you actually need on
the page, and have a single lib which doesn't have to be cut up and
delivered in smaller chunks.

Further, the creation of "multi-purpose chunks" facilitates code sharing and
reuse (see my sites below) while code written by dissenting authors is often
not shared for others to benefit from.
 
M

Manne

Sorry that was a bit vague. I do have some knowledge of programming and
web development. I've read the core guide and feel I could have a go
messing around with other peoples examples.
I was looking for something like this http://rebol.org/ where people
can upload examples of there JS work. The site makes it easy to search
for stuff you might be interested in.
 
D

Dr John Stockton

JRS: In article <[email protected]>, dated Wed, 19 Jul 2006
22:40:01 remote, seen in Matt Kruse
Two points:

1) In many cases, you can't determine which code will be executed. You can
often only determine which code can _possibly_ be executed.

True, which is why I included "substantially". And "be executed" must
of course include all accesses.

It is bad, for example, to import a complete
function DateObjectFromString(Str, WhichOfVeryManyFormats)
into a page which will only use a single hard-coded value for the second
argument.

<URL:http://www.merlyn.demon.co.uk/js-date4.htm#Genl> contains such a
function, but much of the functionality is provided in chunks marked
//optional paragraph
2) If 5 different pages each use 50% of a 10k "multi-purpose chunk" of code,
it is better to deliver the 10k chunk once and let the browser cache it (10k
total download) vs. delivering 5k of page-specific code 5 times (25k total
downloaded).

If all five pages will be fetched. But the longer it takes for the
first page to be fetched, the more likely the reader is to give up and
go elsewhere.
 
M

Matt Kruse

Dr said:
It is bad, for example, to import a complete
function DateObjectFromString(Str, WhichOfVeryManyFormats)
into a page which will only use a single hard-coded value for the
second argument.

If the function is only a few k, then it is certainly not bad. Far better
than including a typical image in a web page.
If all five pages will be fetched. But the longer it takes for the
first page to be fetched, the more likely the reader is to give up and
go elsewhere.

Don't be dramatic. Many pages have 50k or more of images on them. People
don't leave.
Including 10k, 20k, 30k, or more of cache-able javascript is certainly no
worse, and I've never known anyone to actually abandon a site because of
reasonable-size javascript code being delivered to the browser.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top