Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › When to code Javascript yourself or use jquery?
New Posts  All Forums:Forum Nav:

When to code Javascript yourself or use jquery?

post #1 of 16
Thread Starter 
Hi guys,

I'm developing a website right now. As it's a personal website, I want to make parts of it "fancy". I know javascript is a great way to do this and I've heard alot about Javascript and Jquery.

When would you say it's ok to use Jquery? I want to learn whilst doing this website and I've read that it's ok to use jquery for some really advanced stuff but if it's simple, code the javascript yourself. Would you agree?

Considering I want a nice fancy website, are there any tutorials or websites you guys would recommend?

Thanks smile.gif
My Rig
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 3.8 1.256v Asus P6tD Deluxe ATI 5870 12GB Corsair 1600MHz DDR3 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 500GB 1TB + 500GB HDD LG Bluray Writer + DVD RW Noctua u12p 
OSMonitorKeyboardPower
Windows 10 64Bit Dell u2711 Blackwidow Ultimate EVGA Supernova G2 650w 
CaseMouseAudio
Coolermaster HAF 932 Deathadder 3500dpi KRK Rokit RP6 
  hide details  
Reply
My Rig
(16 items)
 
  
CPUMotherboardGraphicsRAM
i7 930 @ 3.8 1.256v Asus P6tD Deluxe ATI 5870 12GB Corsair 1600MHz DDR3 
Hard DriveHard DriveOptical DriveCooling
Samsung EVO 500GB 1TB + 500GB HDD LG Bluray Writer + DVD RW Noctua u12p 
OSMonitorKeyboardPower
Windows 10 64Bit Dell u2711 Blackwidow Ultimate EVGA Supernova G2 650w 
CaseMouseAudio
Coolermaster HAF 932 Deathadder 3500dpi KRK Rokit RP6 
  hide details  
Reply
post #2 of 16
go for javascript.it's easier and you for what you want to do it's a lot better.
this is a very good site to learn from in general.
http://www.w3schools.com/

i wish you the best of luck
post #3 of 16
jQuery is Javascript, it is simply a Javascript Library to make things easier to do.

For example, doing this in Javascript:
Code:
var x = document.getElementsById('my-id')

Is the exact same as this in jQuery:
Code:
var x = $('#my-id')

Once you have that (it is a DOM object), both javascript and jQuery will work with it the exact same way (because it is the same). Therefore, at any given point, you can jump in between and use what is best.

Say I want to get an ID of the first div on the page, then get the id, then add another word to it, I would do this:
Code:
var div = $('div:first'); //use jQuery here, because this selector is much easier to work with
var id = div.prop('id'); //once again, jQuery here because it is simpler (IMO)
var newId = id + 'aNewWord'; //now this is 'normal javascript

Remember, jQuery is Javascript, you don't have to choose. You aren't choosing between them, you use them in tandem, mix-and-match.
post #4 of 16
Quote:
Originally Posted by stupid View Post

jQuery is Javascript, it is simply a Javascript Library to make things easier to do.

For example, doing this in Javascript:
Code:
var x = document.getElementsById('my-id')

Is the exact same as this in jQuery:
Code:
var x = $('#my-id')

Once you have that (it is a DOM object), both javascript and jQuery will work with it the exact same way (because it is the same). Therefore, at any given point, you can jump in between and use what is best.

Say I want to get an ID of the first div on the page, then get the id, then add another word to it, I would do this:
Code:
var div = $('div:first'); //use jQuery here, because this selector is much easier to work with
var id = div.prop('id'); //once again, jQuery here because it is simpler (IMO)
var newId = id + 'aNewWord'; //now this is 'normal javascript

Remember, jQuery is Javascript, you don't have to choose. You aren't choosing between them, you use them in tandem, mix-and-match.
this
Provided that you have some non-javascript programming experience. If you don't you will need to learn the basics of programming before using jQuery.
post #5 of 16
Writing everything in JavaScript by yourself is like inventing the wheel again (and again). Using frameworks like jQuery or Dojo is a good thing to do, but you also have to watch out, especially with jQuery plugins. jQuery plugins are usually written by third parties and if they're dead, it could mean that if you update jQuery, you have to look for an alternative plugin with the same features (and do some refactoring).
post #6 of 16
It doesn't do anything that you can't do yourself. So, if you're doing it for learning and practice then it's probably better to code it all yourself.

I always try to keep 3rd party code to a minimum. So personally, I never include jquery unless I'm already using some other 3rd party code that requires it.
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
Death Star
(21 items)
 
Darksaber
(11 items)
 
 
CPUMotherboardGraphicsRAM
Athlon II x2 245 Asus M3A78 Radeon HD6570 1GB Mushkin Silverline 2GB DDR2  
Hard DriveOptical DriveOSMonitor
OCZ Vertex 2 120GB Samsung Blu-Ray Windows 7 Samsung 46" DLP 
PowerCaseOther
Silverstone Strider Essentials 400W Silverstone Milo ML03B Hauppage WinTV 1250 
  hide details  
Reply
post #7 of 16
Well it depends what it is, but usually using jQuery makes a lot more sense. The point of any programming library is to save time rewriting complex functions over and over again.

Also there are tons of free jQuery CDNs you can use so it won't even cost you additional bandwidth loading the library.
    
CPUMotherboardGraphicsRAM
Intel Core i7 5820K EVGA X99 Micro2 EVGA GTX 980 32GB DDR4-2400 
Hard DriveOSMonitorPower
Samsung 850 Pro Windows 10 x64 Pro Qnix 1440p EVGA 850W Gold 
Case
CaseLabs Mercury S5 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Core i7 5820K EVGA X99 Micro2 EVGA GTX 980 32GB DDR4-2400 
Hard DriveOSMonitorPower
Samsung 850 Pro Windows 10 x64 Pro Qnix 1440p EVGA 850W Gold 
Case
CaseLabs Mercury S5 
  hide details  
Reply
post #8 of 16
Quote:
Originally Posted by stupid View Post

For example, doing this in Javascript:
Code:
var x = document.getElementsById('my-id')

Is the exact same as this in jQuery:
Code:
var x = $('#my-id')

Not quite. The jQuery equivalent would be:
Code:
var x = $('#my-id').get(0)

You jQuery example returns a jQuery object, not a DOM object. The two are not directly interchangeable but are easily convertible, since the jQuery object is more or less a wrapper for zero or more DOM objects which provides lots of nice functionality that you don't normally have OOTB.

As for the topic at hand: I would say that it is always ok to use jQuery unless you can write custom JavaScript that is simpler for your specific situation. However, it's a good idea to understand a bit about what jQuery is doing behind the scenes, especially if you start attaching lots of functionality to browser events that get fired very frequently, or doing things in lengthy loops (try to avoid both in the first place). There is often a very small syntactic difference between jQuery that is fast and jQuery that is slow. What you place inside the magic $() can wildly affect how jQuery finds elements, for example.

Of course while you should always try to use "best practice", spending days optimising something that is technically slow but which is imperceptibly slower than something that is technically fast is a waste of time.

Oh dear, I think I got lost in my own ramblings.
    
CPUMotherboardGraphicsRAM
i7 920 D0 MSI X58 Pro-E GTX 560 Ti 448 3x2GB G.Skill DDR3-1333 9-9-9-24 
Hard DriveHard DriveOptical DriveOS
840 Pro Caviar Black LG BD-ROM Windows 8.1 Pro x64 
MonitorMonitorKeyboardPower
Dell U2713HM Dell U2311H Turbo-Trak (Google it :D) Corsair HX-520 
CaseMouseMouse PadAudio
CM690 Mionix Avior 7000 Everglide Titan AKG K 242 HD 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
i7 920 D0 MSI X58 Pro-E GTX 560 Ti 448 3x2GB G.Skill DDR3-1333 9-9-9-24 
Hard DriveHard DriveOptical DriveOS
840 Pro Caviar Black LG BD-ROM Windows 8.1 Pro x64 
MonitorMonitorKeyboardPower
Dell U2713HM Dell U2311H Turbo-Trak (Google it :D) Corsair HX-520 
CaseMouseMouse PadAudio
CM690 Mionix Avior 7000 Everglide Titan AKG K 242 HD 
  hide details  
Reply
post #9 of 16
Quote:
Originally Posted by wedge View Post

It doesn't do anything that you can't do yourself. So, if you're doing it for learning and practice then it's probably better to code it all yourself.

I always try to keep 3rd party code to a minimum. So personally, I never include jquery unless I'm already using some other 3rd party code that requires it.

With that logic, just dump your OS and write everything in assembly.
post #10 of 16
Quote:
With that logic, just dump your OS and write everything in assembly.

lachen.gif

You made my day tongue.gif
    
CPUMotherboardGraphicsRAM
i3 550 MSI P55-GD80 zotac 280 gtx amp edition 4gb crucial 1600 
Hard DriveOptical DriveOSMonitor
2x250gb raid 0 + 500gb WD caviar, 500gb wd blue Optiarc dvd ram windows 7 pro 23" Digimate 1080p 
KeyboardPowerCaseMouse
compaq stealthxstream 600w Antec nine hundred (dropped from desk :s) g500 
Mouse Pad
belkin gel pad 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
i3 550 MSI P55-GD80 zotac 280 gtx amp edition 4gb crucial 1600 
Hard DriveOptical DriveOSMonitor
2x250gb raid 0 + 500gb WD caviar, 500gb wd blue Optiarc dvd ram windows 7 pro 23" Digimate 1080p 
KeyboardPowerCaseMouse
compaq stealthxstream 600w Antec nine hundred (dropped from desk :s) g500 
Mouse Pad
belkin gel pad 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › When to code Javascript yourself or use jquery?