最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Adding bootstrap in HTML - Stack Overflow

programmeradmin5浏览0评论

I'm going to use bootstrap to build up my front end. Also I'm using JSP and JSTL

What I've read in some articles over the internet is the proper approach of adding an external javascript file should be written before the body closing tag for more optimization of the page. Now I'm trying to apply this with the bootstrap, what i did is put the css of the bootstrap to an external html file:

import_header.html:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap-responsive.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap-responsive.min.css">

which I imported to the head of the html like this:

<jsp:include page="import_header.html" flush="true" />

Now I want to do the same thing with the js file of the of the bootstrap and the jQuery lib but I don't know what is the proper way of doing this.

I'm going to use bootstrap to build up my front end. Also I'm using JSP and JSTL

What I've read in some articles over the internet is the proper approach of adding an external javascript file should be written before the body closing tag for more optimization of the page. Now I'm trying to apply this with the bootstrap, what i did is put the css of the bootstrap to an external html file:

import_header.html:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap-responsive.css">
<link rel="stylesheet" type="text/css" href="bootstrap-css/bootstrap-responsive.min.css">

which I imported to the head of the html like this:

<jsp:include page="import_header.html" flush="true" />

Now I want to do the same thing with the js file of the of the bootstrap and the jQuery lib but I don't know what is the proper way of doing this.

Share Improve this question edited Apr 13, 2015 at 3:06 Freedom_Ben 12k10 gold badges78 silver badges90 bronze badges asked Oct 12, 2013 at 6:17 newbienewbie 1,9807 gold badges34 silver badges55 bronze badges 3
  • You mean that you want to include them in your main html file? As is <script src="js/jquery.js"> insert right before the body closing tag? – EmptyArsenal Commented Oct 12, 2013 at 6:24
  • What I did above is make an external html file where I already link all css files then I will only include 1 file in the html file. If I do what your suggesting. I have to include 4 js file every time I create a new page. – newbie Commented Oct 12, 2013 at 6:32
  • Yeah, that's how it goes. Use some of the js frameworks, and you'll have to include a dozen files. Trying to include them in an external like you did with your css files seems unnecessary. – EmptyArsenal Commented Oct 12, 2013 at 6:40
Add a ment  | 

1 Answer 1

Reset to default 11

that's the remended way, how to place them:

e.g. footer.html

        <!-- Placed at the end of the document so the pages load faster -->
        <script src="jquery/jquery-2.0.3.min.js"></script>
        <script src="bootstrap/bootstrap-2.3.1.min.js"></script>
        <script src="myOwn.js"></script>
    </body>
</html>
发布评论

评论列表(0)

  1. 暂无评论