0

And if so where would I put the second page of code. From reading some of the other questions here I finally realized that I needed to separate my javascript(jquery) code from my html which also helped with using a variable from one file to the next, however I have a second page of javascript(jquery) and I'm not sure how I should organize it all? or should I simply make another .js file for the second page? and then have two tags to both files?

2
  • 2
    This is not a question, it is a lot of questions and a mess. Think out what you want to ask and be specific. A jumble like this won't get good answers. See the [faq] Commented Jan 25, 2013 at 18:55
  • Yeah, if this wasn't my FIRST time doing this type of programming I would have been more specific. Didn't really know what to ask since I don't know what protocols or design methods to use. MORE SPECIFICALLY can I put my second page of javascript code at the end of my first page of js code in the same file???? Commented Jan 25, 2013 at 21:36

3 Answers 3

0

No, no, no, write organized and readable code. Separate HTML, CSS and JS code, assets and keep them well organized.

see this How to organization JavaScript code in project for maintainability?

Sign up to request clarification or add additional context in comments.

5 Comments

He can't even write an organized question -- there is no hope.
@Hogan really, sorry almighty one that some of us are just learning want questions too asks or were you born knowing this?? Is that specific enough
@jc72, No. That is not a programming question. Being snide and irate does not get your questions answered. Like I said, read the faq, if you do.... that will help.
Thanks Nikola that answers my question
@Hogan your right you were snide and irate and I was just responding to acting like how dare I ask such a question instead of just saying "NOT A PROGRAMMING QUESTION, PLEASE READ THE FAQ", then you say I can't even write an organized question that's just rude and not needed. I would have just read the faq and said my fault without all your extra comments
0

If you use jquery, you should use the file hosted by Google, because Google's connection is so fast and lots of people use that file, so it is likely that your client's browser will have the file in its caché (and this way you avoid downloading, so your page will load faster).

For more information, read http://encosia.com/3-reasons-why-you-should-let-google-host-jquery-for-you/

And the js code which is not the jquery library, it doesn't matter very much if you use a single or multiple files, but I guess that each file needs a new request with all its headers. Then, avoid having very small .js files, join them instead.

Comments

0

You should organize you JS by functionality and than decide in each page what to load based on the functionality that you need, A good example is with jQuery plugins. You can have a file that load the jQuery plugins with all the configuration that you need and include that file every time that you need to use the plugin. You can that create a .js file with all th functionality for the specific page. You will load that js only in the page that requires that functionality. You can load JS file also in the js code by calling jQuery,getScript()

See here for more

I hope this was useful and clear

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.