Javascript 如何加速PayPal JS SDK的导入以加速对话框中按钮的加载?

Javascript 如何加速PayPal JS SDK的导入以加速对话框中按钮的加载?,javascript,html,css,google-apps-script,paypal,Javascript,Html,Css,Google Apps Script,Paypal,我想在一个对话框中显示我的谷歌工作表上的PayPal按钮。问题是,在用户启动操作后,对话框需要很长时间(3到4秒)才能显示。我认为问题的发生是因为我使用CDN和脚本标记导入JS,如下所示: <script src="https://www.paypal.com/sdk/js?client-id=SB_CLIENT_ID" /> index.html //必需的。用您的沙盒客户端ID替换SB_客户端ID。 paypal.Buttons().render(“#paypal按钮容器”)

我想在一个对话框中显示我的谷歌工作表上的PayPal按钮。问题是,在用户启动操作后,对话框需要很长时间(3到4秒)才能显示。我认为问题的发生是因为我使用CDN和脚本标记导入JS,如下所示:

<script src="https://www.paypal.com/sdk/js?client-id=SB_CLIENT_ID" />
index.html

//必需的。用您的沙盒客户端ID替换SB_客户端ID。
paypal.Buttons().render(“#paypal按钮容器”);
//此功能在网页上显示智能支付按钮。

long time(长时间)-你怎么称呼长时间?@JaromandaX:3到4秒。我现在就编辑这个问题,让它更具体一些。看一看可能对你有用的答案。但是本地文件也可以工作。@Cooper:但是我如何在代码中导入本地文件呢?气体没有
require()
或类似的东西。对吗?你有没有把那3到4秒内发生的事情分解一下?浏览器开发工具对于这种长时间的分析是很好的——你称之为长时间是什么?@JaromandaX:3到4秒。我现在就编辑这个问题,让它更具体一些。看一看可能对你有用的答案。但是本地文件也可以工作。@Cooper:但是我如何在代码中导入本地文件呢?气体没有
require()
或类似的东西。对吗?你有没有把那3到4秒内发生的事情分解一下?浏览器开发工具非常适合这种分析
  // Display a modal dialog box with custom HtmlService content.
  var htmlOutput = HtmlService.createHtmlOutputFromFile(FILENAME)
  SpreadsheetApp.getUi().showModalDialog(htmlOutput, TITLE);
<!DOCTYPE html>
<!-- source: https://developer.paypal.com/docs/checkout/integrate/ -->

<head>
  <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Ensures optimal rendering on mobile devices. -->
  <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <!-- Optimal Internet Explorer compatibility -->
</head>

<body>
  <script
    src="https://www.paypal.com/sdk/js?client-id=SB_CLIENT_ID"> // Required. Replace SB_CLIENT_ID with your sandbox client ID.
  </script>

  <div id="paypal-button-container"></div>

  <script>
    paypal.Buttons().render('#paypal-button-container');
    // This function displays Smart Payment Buttons on your web page.
  </script>

</body>