admin管理员组文章数量:1290944
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?
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?
Share Improve this question edited Aug 28, 2012 at 1:49 Marcelo De Polli 29.3k4 gold badges40 silver badges47 bronze badges asked Aug 28, 2012 at 1:37 kaskaykaskay 671 silver badge5 bronze badges 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. – thomasrutter 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. – Marcelo De Polli Commented Aug 28, 2012 at 2:04
-
You
re 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 don
t 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? – kaskay Commented Aug 28, 2012 at 8:51
2 Answers
Reset to default 9Just 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>
I would remend 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 bine and minify the files. As for the different css, html and javascript. Those should all remain in separate files. But minifying your files and bining 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.
本文标签: javascriptseparate files (HTML5CSS amp JS)Stack Overflow
版权声明:本文标题:javascript - separate files (HTML5,CSS & JS) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741522599a2383277.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论