Resolved: Load bootstrap table from external file


I want to load the table.html file, which contains a table with bootstrap classes, on the index page. The problem is that it does not get style after loading the table. What is the reason? If I import bootstrap libraries in the table.html file, my problem will be solved, but this solution is not suitable because for each bootstrap library call is loaded, I want to import the desired libraries only once in the index page, and each time my tables load in it.
here is my code: (you can also see
<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

        var cache = null;

    <link rel="stylesheet" href="lib/bootstrap/css/bootstrap.rtl.min.css">
    <link rel="stylesheet" href="lib/table/bootstrapTable/css/bootstrap-table.min.css">

    <script src="lib/jquery/jquery-3.6.0.min.js"></script>
    <script src="lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="lib/table/bootstrapTable/js/bootstrap-table.min.js"></script>

    <input type="text" id="name">
    <input type="text" id="price">
    <input type="text" id="age">
    <button onclick="cache = $('body'); $('body').load('table.html');">load table</button>
table.html :
    data-classes="table table-striped table-hover table-bordered"
    data-toolbar=".toolbar" data-maintain-meta-data="true" tabindex="-1"
            <th data-checkbox="true"></th>
            <th data-field="name">name</th>
            <th data-field="price">price</th>
            <th data-field="day">day</th>


You need to rerun the scripts when you add new contents. Just add following code at the end of table.html:
Here is the working demo on codepen.

If you don’t want to target all the tables then you can also use:

If you have better answer, please add a comment about this, thank you!