Advantages and disadvantages of loading html templates in this way

1. Today, when I maintained the old code of the company, I saw some of the old code. The purpose of this code is to load the html template.

//index.htmljs

$("div").load("templateOfchart.html");//templateOfchart.html 

content in 2.templateOfchart.html

<!DOCTYPE html>
<html>
<head>    
    <meta charset="utf-8">
    <title></title>
</head>
<body>
********
</body>
</html>

3. Such a page has some duplicate tags, such as meta title. Is this good?
if I improve, how can I improve?

4. I wonder how the front end is programmed and how it evolves when there are no frameworks such as vue. I hope the great gods can introduce some information or point out the direction. Thank you very much.

Mar.01,2021

answer question 4, jstraining by ruanyifeng


  1. all right? Not so good, it's easy to bring potential problems. For example, it is stated in the standard that < / body > do not add page content, but if you add it forcefully, it does not mean that the browser will not render it, but it still cannot be done in this way, is it?
  2. how to solve this problem? There are two ways to write it. First, delete all the things you don't want to do in the template; second, .load () can load HTML fragments, and the part you want to load is packaged with an ID, and written into .load ('template.html-sharpapp') . Try this format.
  3. . The question is too big to answer. It is suggested that you can look at the js template and js's mvc framework (the three pioneers). In addition, you can also take a look at Mr. Stu's book.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3310c-2b1c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3310c-2b1c9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?