TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Javascript, AJAX, E4X (http://www.talkphp.com/javascript-ajax-e4x/)
-   -   Basics or jQuery? (http://www.talkphp.com/javascript-ajax-e4x/4837-basics-jquery.html)

devnull 08-10-2009 03:13 PM

Basics or jQuery?
 
Just something I thought to myself, reading another thread on this same forum, that I would like to share is the discussion surrounding whether people that are new to javascript should start with the basics, not programming basics but rather basics on how to manipulate the DOM, or go straight into jQuery.

Now for those of you that do not know, jQuery is a popular javascript library that makes the use of javascript as a programming language "easier", in some cases I fully agree it does, but as with all libraries or frameworks this comes at a disadvantage, being the size of it, where sometimes all you need to do is hide a div, which can be written in a total of 1 line of code.

<rant>Every time you then need to go hide that div, this whole library will be loaded, yes it is small but the fact still exists that using the library for something so simple is bloating websites/applications all over the net, just to have a quick look at the uncompressed version of the latest jQuery library which is 120kb, sounds small hey? Coming in at 4327 lines of code it really is not that small.</rant>

Without going completely off topic, I reckon a user should first know what the DOM actually is, what are elements, how do you manipulate the DOM, what is ajax actually, before jumping into a library which will help reduce the amount of code for larger/complex web applications.

So, basics or jQuery?

Enfernikus 08-10-2009 03:40 PM

Basics obviously, you can't fully take advantage of jQuery without having an understanding of DOM.

Salathe 08-10-2009 04:11 PM

I'd go so far as to say they should learn much more than merely the basics before diving into any of the frameworks available. Unless they're the type who really don't want to learn the language but rather just get the job done.

Would you recommend someone jumps right in using the Zend Framework, Symfony, etc. before knowing the first thing about PHP? I certainly wouldn't!

codefreek 08-10-2009 04:45 PM

Sometimes, learning the hard first can be a good thing.
But can also damage the learning process.
And in the end you end up beeing overwhelmed,
so start small and go up slowly

-CF

JaoudeStudios 08-10-2009 05:26 PM

Definitely learn php before zend framework and definitely learn the basics of javascript before jquery.

sketchMedia 08-11-2009 09:00 AM

Basics are very important, you need to know how javascript fully works at a relatively advanced level (at least know how its object model works), this is because jQuery uses a lot of advanced level javascript concepts that may just seem like 'black magic' to people without the necessary grounding in the language. This limited understanding can lead to bad and somewhat slow code.

devnull 08-11-2009 12:55 PM

Quote:

Originally Posted by JaoudeStudios (Post 27678)
Definitely learn php before zend framework and definitely learn the basics of javascript before jquery.

Contradicting yourself a bit then aren't you?

http://www.talkphp.com/javascript-aj...avascript.html

Village Idiot 08-11-2009 01:57 PM

You can learn how to use jquery without knowing DOM, but you will not understand what is happening until you know how jquery works.

adamdecaf 08-11-2009 04:05 PM

Quote:

Originally Posted by Village Idiot (Post 27687)
You can learn how to use jquery without knowing DOM, but you will not understand what is happening until you know how jquery works.

JavaScript is essential to knowing how to do JQuery scripts that are beyond trivial.

devnull 08-11-2009 04:16 PM

Quote:

Originally Posted by adamdecaf (Post 27701)
JavaScript is essential to knowing how to do JQuery scripts that are beyond trivial.

Agreed, using jQuery without knowing what it is actually doing is a disaster waiting to happen, true you get extensions that make your life easier but what happens when you need to change something in that extension?

Enfernikus 08-11-2009 04:19 PM

Nay the disaster is when you do this:

javascript Code:
$("#imgID").attr('src', 'http://google.com/img.png');

instead of

javascript Code:
document.getElementById('imgID').setAttribute('src', 'http://google.com/img.png');

Enfernikus 08-11-2009 04:20 PM

Nay the disaster is when you do this:

javascript Code:
$("#imgID").attr('src', 'http://google.com/img.png');

instead of

javascript Code:
document.getElementById('imgID').setAttribute('src', 'http://google.com/img.png');

I've seen the jQuery library - uncompressed - be called into web apps for the sole purpose of changing some attributes.

adamdecaf 08-11-2009 04:30 PM

Yep, I've actually found JS very simple compared to JQuery.

devnull 08-11-2009 04:37 PM

Quote:

Originally Posted by Enfernikus (Post 27704)
I've seen the jQuery library - uncompressed - be called into web apps for the sole purpose of changing some attributes.

More than often :/

Just for interest sake anybody want to benchmark that? Still at work will do when I get home

adamdecaf 08-12-2009 12:24 AM

Quote:

Originally Posted by devnull (Post 27707)
More than often :/

Just for interest sake anybody want to benchmark that? Still at work will do when I get home

Something like this? http://selectors.turnwheel.com/
Also, run the test for yourself. http://selectors.turnwheel.com/slickspeed.php

Salathe 08-12-2009 10:19 AM

Quote:

Originally Posted by Enfernikus (Post 27704)
I've seen the jQuery library - uncompressed - be called into web apps for the sole purpose of changing some attributes.

If you bring in the library from some CDN then the impact might be bearable: the main example being loading jQuery from the Google AJAX Libraries API. The idea being that the client would hopefully already have the file cached.

JaoudeStudios 08-12-2009 10:25 AM

Its difficult to find a balance. But some understanding of javascript is need before using jQuery. For example conditional statements in jQuery are still javascript.

Enfernikus 08-12-2009 11:19 AM

Quote:

Originally Posted by Salathe (Post 27725)
If you bring in the library from some CDN then the impact might be bearable: the main example being loading jQuery from the Google AJAX Libraries API. The idea being that the client would hopefully already have the file cached.

You've a good point but the idea is not the fact that the file must be downloaded and might affect load times but rather that for the simple task of changing attributes the library was needed. This was the only JS on the site ( Intranet tool, the company wasn't big on facy UI's internally )

sketchMedia 08-12-2009 01:37 PM

Its all about balance, you wouldn't use the Zend framework for a site with static content, would you? In the case above, yes jQuery is probably overkill.

Quote:

Yep, I've actually found JS very simple compared to JQuery.
All very well and good for simple examples like that but when you start doing some advanced standard compliant DOM stuff with native JS, it gets very painful indeed (especially when redmond is in the equation) jQuery takes alot of the pain away from that!

JaoudeStudios 08-12-2009 03:10 PM

jQuery takes the pain away from cross-browser issues too! That in itself is worth a lot! (especially because IE is poo - any chance i get to have a dig at windows - with valid reason ofcourse :) )


All times are GMT. The time now is 01:33 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0