3

I have recently developed my first mobile web application using HTML5, CSS3, JavaScript and a bit of jQuery. At this stage I want to separate codes for HTML, CSS & JS in 3 different files and using a web server to establish connection between those files. Any solution?

3
  • 2
    It's difficult to tell what's being asked here. It looks like the question is asking, "How do I put my HTML, CSS and JS into 3 separate files?" The answer is "By putting them into 3 separate files". We have no way of knowing where it is that you're getting stuck. Commented Aug 28, 2012 at 1:55
  • Particularly your mention of a web server is really confusing, because I can't think of any other way to serve HTML, CSS and JS files. Commented Aug 28, 2012 at 2:04
  • Youre right.I know my questions might looks silly to a web developer.As this is my first experience working with markup languages as well as web application(so far I have worked with Java and C#).Also I dont know about web architecture and web services.Simply I meant if I separate HTML5,CSS3 and JS in different files and store them in a single folder how should they be referenced according to one another? Commented Aug 28, 2012 at 8:51

2 Answers 2

9

Just declare references to your CSS & JS from within your HTML. For performance reasons, it's good to put the CSS reference in the head, and the JS reference at the end of the file just before closing out the tag. That way, your page will load and will look correct right off the bat and won't be blocked downloading the JavaScript. The JS will be the last thing to load. Here's an example of the HTML markup:

<html>
<head>
<link rel="stylesheet" type="text/css" href="mystyles.css" />
</head>

<body>
...

<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="myscript.js"></script>

</body>
</html>
Sign up to request clarification or add additional context in comments.

Comments

0

I would recommend looking into builders like

  • Apache Ant
  • HTML5 Boilerplate Build Script
  • Grunt (based on node.js)
  • Make or Rake files

this allows you to separate all of your files and then lint the files. This also allows you to then combine and minify the files. As for the different css, html and javascript. Those should all remain in separate files. But minifying your files and combining them into single files will definitely reduce page load time.

A good reading and look through would be HTML5 Boilerplate. They spend a lot of time on performance and the developer process.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.