Home › Forums › JavaScript › Getting three scripts to work on one page. possible??
- This topic is empty.
-
AuthorPosts
-
March 20, 2013 at 2:23 pm #129018rpotterjrParticipant
Ok, so what is your level of knowledge on HTML, CSS?
March 20, 2013 at 2:25 pm #129019rpotterjrParticipantIt 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…
March 20, 2013 at 2:33 pm #129021rpotterjrParticipantEnsure 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…
March 20, 2013 at 2:37 pm #129022rpotterjrParticipantAlso, 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…
March 20, 2013 at 2:39 pm #129023rpotterjrParticipantIf 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…
March 21, 2013 at 11:01 am #129167scribbleartMemberThank 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.
March 21, 2013 at 11:09 am #129169Paulie_DMember> 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.
April 12, 2013 at 6:51 am #131511rpotterjrParticipantLike 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.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.