Doing 'Javascript the Right way'

Discussion in 'HTML & Website Design' started by webjames, Sep 20, 2007.

  1. #1
    hey guys: this might be a totally dumb question because i'm still learning things. I understand the principle of doing websites the 'right way' with web standards (CSS for Presentation/HTML for markup). And seeing how using DW/WYSWYG is not accurate and clean code.

    My question is, what about using DW's built-in JS behaviors? Would this also be going about it from the wrong standpoint in using JS? Is there a better accurate way to do JS 'the right way' or does it not matter from this standpoint? I hope this makes sense.
     
    webjames, Sep 20, 2007 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Don't use it. The code is often bloated and designed to cater to every possible situation (including Netscape 2 and Internet Explorer 3!), often relies on browser sniffing instead of object detection and often gets inlined with the HTML file.

    If you're going to use JavaScript (including Ajax), make sure the files are as unobtrusive as possible (meaning they are contained in external files and attached dynamically by corresponding with ID attributes or injecting custom class names into the DOM), accessible, and are written (and executed) with progressive enhancement (not graceful degredation) in mind and use the bare minimum of code to prevent memory issues.
     
    Dan Schulz, Sep 20, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Dan, that is reminiscent of older versions of Dreamweaver. The new versions have options to not bother supporting low end browsers (e.g. NS4), have less browser detection by user agent and not certain about this, but it can also be configured to use your external JS files.

    Definitely doesn't beat doing this "by hand", but it is viable for those with little JS background.
     
    krt, Sep 20, 2007 IP
  4. webjames

    webjames Peon

    Messages:
    42
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    thanks for the response dan/krt.
    I am an artist first before a coder but i have found that learning
    css/html is not so 'overly technical' and i can handle that code without hindering my time and mind for creative work.
    Javascript by hand...oooh....i don't know. I guess I need to look into this more. Maybe check out 'Simply Javascript' by sitepoint. I appreciate the explanations. I am also working with Flash and may go towards actionscript.
     
    webjames, Sep 20, 2007 IP
  5. soulscratch

    soulscratch Well-Known Member

    Messages:
    964
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    155
    #5
    I do not recommend that book. Get Jeremy Keith - DOM Scripting to learn some basic modern Javascript. The book doesn't go that deep into JS techniques, it's more of a best practices book that's friendly to beginners. After that you can read something like Chris Heilmann's Beginning Javascript and DOM Scripting (which is not as newbie friendly as Jeremy's book). It has lots more techniques though.
     
    soulscratch, Sep 20, 2007 IP
  6. ass45sin

    ass45sin Peon

    Messages:
    115
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for the recommendation webjames and soulscratch.. I am new to all this web programming.
     
    ass45sin, Sep 20, 2007 IP
  7. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I'm going to second the call against "Simply JavaScript" - UNLESS - you are content being taught how to code using a JavaScript library, rather than learning how to code to the spec, then incorporating a custom library that you can reuse later.

    In other words, if you don't mind letting a library do all the heavy lifting while you learn the basics of the language, then yes, "Simply JavaScript" will be good enough for you. However, if you want to learn how to create your own JavaScript applications, then this book will not be for you unless you're willing to undertake a huge learning curve afterword and break away from using pre-fab custom libraries.
     
    Dan Schulz, Sep 20, 2007 IP