Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Getting three scripts to work on one page. possible??

  • This topic is empty.
Viewing 8 posts - 16 through 23 (of 23 total)
  • Author
    Posts
  • #129018
    rpotterjr
    Participant

    Ok, so what is your level of knowledge on HTML, CSS?

    #129019
    rpotterjr
    Participant

    It is very possible to have three scripts on the same page, however, you need to ensure that nothing is conflicting such as duplicate identifiers in your js and/or duplicate ids and/or classes in your css…

    #129021
    rpotterjr
    Participant

    Ensure that you always call for your external documents (meaning outside the page) into your <'head'> section of your page in the following order:

    Stylesheets (CSS)

    JavaScript Library (jQuery in your case)

    jQuery Scripts

    Inline jQuery Scripts

    Don’t call a secondary script before you’re done with the first script. You want to make sure that you work on one at a time, typically from the top of the page down, before continuing onto the next one. This way it is easier to locate and troubleshoot your problems…

    #129022
    rpotterjr
    Participant

    Also, with CSS it is best to have everything in a single stylesheet (as much as possible) and use section labeling in the document to locate specific areas for modification. The reason being that it adds to your load time calling more documents. Browsers typically load 1-2 files at a time. This can be modified on your side, but regardless, the end-users will only have the limit of 1-2. Same goes with images. Best practice is to use sprites…

    #129023
    rpotterjr
    Participant

    If I am losing you at this point, I’m afraid that you have much to learn before taking on website development/ design. If you’re still with me, then let me know where you are at. If you would like, you can send me your files in a zip and I can take a look through them…

    #129167
    scribbleart
    Member

    Thank you. I have a good working knowledge of HTML and CSS. And I try to put everything into one CSS file.- Except -when I add a JS script, I usually add a style sheet for it.

    #129169
    Paulie_D
    Member

    > Always place your JavaScript in the <'head'> section! I know I may get a lot of haters on this, but don’t do that.

    You sure will.

    In a lot of cases, the JS isn’t needed until the page is fully loaded. So that the bottom of the page is the place to ‘activate’ that JS.

    If you put modernizer or responsive.js in the footer the screen will have to redraw / repaint based on that JS after it’s already loaded / painted.

    By all means put **essential** scripts in the head. Other scripts can wait until the end. In fact, I dare to say, that’s best practise.

    #131511
    rpotterjr
    Participant

    Like I said, I know I would get haters on what I said about placing your JavaScript in the <'head'> section, however… Some older browsers will sometimes ignore it and you may even have errors falsely reporting in the console. I spent quite a few weeks on a clients website (quite large with a lot of JS dependencies), along side two other veteran designers, having to re-structure their website because a lot of things were going haywire due to calling JS at the end of the document.

Viewing 8 posts - 16 through 23 (of 23 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.