CINXE.COM
How to optimize square code - Questions - Square Developer Forums
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>How to optimize square code - Questions - Square Developer Forums</title> <meta name="description" content="I made a test version of my shopping cart that I ran through google pagespeed insights, and it reports that squares own code takes 1/2 a second to complete and a few hundred extra KB to download which might be too much f&hellip;"> <meta name="generator" content="Discourse 3.5.0.beta1-dev - https://github.com/discourse/discourse version 402ec6bf5c857ddc07be9cb9673734cc7152b7be"> <link rel="icon" type="image/png" href="https://global.discourse-cdn.com/square/optimized/1X/3d63b02e565ccf34bc21e579b8efe21191bc3de6_2_32x32.png"> <link rel="apple-touch-icon" type="image/png" href="https://global.discourse-cdn.com/square/optimized/1X/3d63b02e565ccf34bc21e579b8efe21191bc3de6_2_180x180.png"> <meta name="theme-color" media="all" content="#ffffff"> <meta name="color-scheme" content="light"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, viewport-fit=cover"> <meta name="discourse-base-uri" content="/forums"> <link rel="canonical" href="https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802" /> <link rel="search" type="application/opensearchdescription+xml" href="https://developer.squareup.com/forums/opensearch.xml" title="Square Developer Forums Search"> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/color_definitions_square-light_2_3_30b89a50275cb63dd6fc0d30364dfc4c966c13c1.css?__ws=developer.squareup.com" media="all" rel="stylesheet" class="light-scheme"/> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/desktop_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="desktop" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/checklist_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="checklist" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-ai_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-ai" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-akismet_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-akismet" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-assign_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-assign" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-cakeday_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-cakeday" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-chat-integration_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-chat-integration" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-data-explorer_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-data-explorer" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-details_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-details" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-lazy-videos_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-lazy-videos" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-local-dates_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-local-dates" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-narrative-bot_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-narrative-bot" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-policy_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-policy" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-presence_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-presence" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-solved_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-solved" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-templates_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-templates" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-topic-voting_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-topic-voting" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-user-notes_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-user-notes" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/footnote_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="footnote" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/hosted-site_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="hosted-site" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/poll_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="poll" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/spoiler-alert_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="spoiler-alert" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-ai_desktop_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-ai_desktop" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/discourse-topic-voting_desktop_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="discourse-topic-voting_desktop" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/poll_desktop_fe2a09b0b7b02b237aa3cfb00c7b5af9badde726.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="poll_desktop" /> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/desktop_theme_5_ae15acffac9b1865932e09db4adf66ec8b0bcc80.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="5" data-theme-name="cookie consent banner"/> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/desktop_theme_10_c58f7982af34fc0419f8236e0cbb73de14e49e3b.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="10" data-theme-name="discourse-disclosure-theme"/> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/desktop_theme_3_28641b014b18c50ed69d2c98ffde5a9ce7604728.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="3" data-theme-name="discourse-square-theme"/> <link href="https://sea1.discourse-cdn.com/square/forums/stylesheets/desktop_theme_6_ffec9401dace9a32d5b0f23876ab316b22ec2863.css?__ws=developer.squareup.com" media="all" rel="stylesheet" data-target="desktop_theme" data-theme-id="6" data-theme-name="squaresansfont"/> <meta name="google-site-verification" content="p6R9Eo6pW5cWj0ZixjudKwZ1NxgZyRHcbBAnNt1Dn9o"> <script defer="" src="https://sea1.discourse-cdn.com/square/forums/theme-javascripts/f781e9cd70b959f0256e92900b82905e063e68c4.js?__ws=developer.squareup.com" data-theme-id="3" nonce="wEE6m7Iz6K9cM9M98IpPRchYV"></script> <script defer="" src="https://sea1.discourse-cdn.com/square/forums/theme-javascripts/56e1a085b96460508e7722429a2e5efb0f10e8cf.js?__ws=developer.squareup.com" data-theme-id="5" nonce="wEE6m7Iz6K9cM9M98IpPRchYV"></script> <link rel="alternate nofollow" type="application/rss+xml" title="RSS feed of 'How to optimize square code'" href="https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802.rss" /> <meta property="og:site_name" content="Square Developer Forums" /> <meta property="og:type" content="website" /> <meta name="twitter:card" content="summary" /> <meta name="twitter:image" content="https://global.discourse-cdn.com/square/original/2X/c/cd67f719136a922c7c7f401ef340b5c64ef70807.png" /> <meta property="og:image" content="https://global.discourse-cdn.com/square/original/2X/c/cd67f719136a922c7c7f401ef340b5c64ef70807.png" /> <meta property="og:url" content="https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802" /> <meta name="twitter:url" content="https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802" /> <meta property="og:title" content="How to optimize square code" /> <meta name="twitter:title" content="How to optimize square code" /> <meta property="og:description" content="I made a test version of my shopping cart that I ran through google pagespeed insights, and it reports that squares own code takes 1/2 a second to complete and a few hundred extra KB to download which might be too much for some users to handle. The 1/2 second could make some users think their devices are locking up. Is there a setting I can use when calling square.js to try to make the speed faster so people stuck under a bridge that can only browse the internet at dial-up speeds can complete a..." /> <meta name="twitter:description" content="I made a test version of my shopping cart that I ran through google pagespeed insights, and it reports that squares own code takes 1/2 a second to complete and a few hundred extra KB to download which might be too much for some users to handle. The 1/2 second could make some users think their devices are locking up. Is there a setting I can use when calling square.js to try to make the speed faster so people stuck under a bridge that can only browse the internet at dial-up speeds can complete a..." /> <meta property="og:article:section" content="Questions" /> <meta property="og:article:section:color" content="006BE6" /> <meta property="og:article:tag" content="payments-api" /> <meta property="article:published_time" content="2024-11-24T02:52:51+00:00" /> <meta property="og:ignore_canonical" content="true" /> <script type="application/ld+json">{"@context":"http://schema.org","@type":"QAPage","name":"How to optimize square code","mainEntity":{"@type":"Question","name":"How to optimize square code","text":"I made a test version of my shopping cart that I ran through google pagespeed insights, and it reports that squares own code takes 1/2 a second to complete and a few hundred extra KB to download which might be too much for some users to handle. The 1/2 second could make some users think their device…","upvoteCount":0,"answerCount":0,"datePublished":"2024-11-24T02:52:51.328Z","author":{"@type":"Person","name":"osd3","url":"https://developer.squareup.com/forums/u/osd3"}}}</script> </head> <body class="crawler browser-update"> <div class="background-container"></div> <header> <a href="/forums/"> Square Developer Forums </a> </header> <div id="main-outlet" class="wrap" role="main"> <div id="topic-title"> <h1> <a href="/forums/t/how-to-optimize-square-code/19802">How to optimize square code</a> </h1> <div class="topic-category" itemscope itemtype="http://schema.org/BreadcrumbList"> <span itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"> <a href="/forums/c/questions/7" class="badge-wrapper bullet" itemprop="item"> <span class='badge-category-bg' style='background-color: #006BE6'></span> <span class='badge-category clear-badge'> <span class='category-name' itemprop='name'>Questions</span> </span> </a> <meta itemprop="position" content="1" /> </span> </div> <div class="topic-category"> <div class='discourse-tags list-tags'> <a href='https://developer.squareup.com/forums/tag/payments-api' class='discourse-tag' rel="tag">payments-api</a> </div> </div> </div> <div itemscope itemtype='http://schema.org/DiscussionForumPosting'> <meta itemprop='headline' content='How to optimize square code'> <link itemprop='url' href='https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802'> <meta itemprop='datePublished' content='2024-11-24T02:52:51Z'> <meta itemprop='articleSection' content='Questions'> <meta itemprop='keywords' content='payments-api'> <div itemprop='publisher' itemscope itemtype="http://schema.org/Organization"> <meta itemprop='name' content='Square'> <div itemprop='logo' itemscope itemtype="http://schema.org/ImageObject"> <meta itemprop='url' content='https://global.discourse-cdn.com/square/original/2X/1/16e2ce72088e5dc25884d55753dbf3791edf084d.svg'> </div> </div> <div id='post_1' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://developer.squareup.com/forums/u/osd3'><span itemprop='name'>osd3</span></a> </span> <link itemprop="mainEntityOfPage" href="https://developer.squareup.com/forums/t/how-to-optimize-square-code/19802"> <link itemprop="image" href="https://global.discourse-cdn.com/square/original/2X/c/cd67f719136a922c7c7f401ef340b5c64ef70807.png"> <span class="crawler-post-infos"> <time datetime='2024-11-24T02:52:51Z' class='post-time'> November 24, 2024, 2:52am </time> <meta itemprop='dateModified' content='2024-11-24T02:52:51Z'> <span itemprop='position'>1</span> </span> </div> <div class='post' itemprop='text'> <p>I made a test version of my shopping cart that I ran through google pagespeed insights, and it reports that squares own code takes 1/2 a second to complete and a few hundred extra KB to download which might be too much for some users to handle. The 1/2 second could make some users think their devices are locking up.</p> <p>Is there a setting I can use when calling square.js to try to make the speed faster so people stuck under a bridge that can only browse the internet at dial-up speeds can complete an order without waiting for extra stuff to download?</p> <p>These are the results from google pagespeed insights with the concerning numbers underlined in red.</p> <p>The higher ms numbers are there because on my website I loaded everything sequentially.</p> <p><div class="lightbox-wrapper"><a class="lightbox" href="https://global.discourse-cdn.com/square/original/2X/c/cd67f719136a922c7c7f401ef340b5c64ef70807.png" data-download-href="/forums/uploads/short-url/tj6CO0qbCPqUsgV0KF6m2zjipAH.png?dl=1" title="sq" rel="noopener nofollow ugc"><img src="https://global.discourse-cdn.com/square/original/2X/c/cd67f719136a922c7c7f401ef340b5c64ef70807.png" alt="sq" data-base62-sha1="tj6CO0qbCPqUsgV0KF6m2zjipAH" width="469" height="500" data-dominant-color="FAFAFA"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">sq</span><span class="informations">727脳775 12.8 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><br> <div class="lightbox-wrapper"><a class="lightbox" href="https://global.discourse-cdn.com/square/original/2X/b/b58d49967d191b6f11b6dc3c7627b873281ac10f.png" data-download-href="/forums/uploads/short-url/pU580lrEtB41pz6ekshLOusIJrN.png?dl=1" title="sq2" rel="noopener nofollow ugc"><img src="https://global.discourse-cdn.com/square/original/2X/b/b58d49967d191b6f11b6dc3c7627b873281ac10f.png" alt="sq2" data-base62-sha1="pU580lrEtB41pz6ekshLOusIJrN" width="414" height="500" data-dominant-color="FBFBFB"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">sq2</span><span class="informations">726脳876 11.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_2' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://developer.squareup.com/forums/u/Square-Dev-AI'><span itemprop='name'>Square-Dev-AI</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2024-11-24T02:53:06Z' class='post-time'> November 24, 2024, 2:53am </time> <meta itemprop='dateModified' content='2024-11-24T02:53:06Z'> <span itemprop='position'>2</span> </span> </div> <div class='post' itemprop='text'> <p><img src="https://emoji.discourse-cdn.com/apple/wave.png?v=12" title=":wave:" class="emoji" alt=":wave:" loading="lazy" width="20" height="20"> I鈥檓 Square Dev AI, here to help answer your question!<br> Based on the information you鈥檝e provided, the following documentation will help answer your question:</p><aside class="onebox allowlistedgeneric" data-onebox-src="https://developer.squareup.com/docs/pos-api/build-mobile-web"> <header class="source"> <img src="https://global.discourse-cdn.com/square/original/2X/f/f587a741c8dbedfcb8cb680873adb3eb6643d1de.png" class="site-icon" data-dominant-color="000000" width="32" height="32"> <a href="https://developer.squareup.com/docs/pos-api/build-mobile-web" target="_blank" rel="noopener">Square Developer</a> </header> <article class="onebox-body"> <h3><a href="https://developer.squareup.com/docs/pos-api/build-mobile-web" target="_blank" rel="noopener">Build on Mobile Web</a></h3> <p>Open the Square Point of Sale application from a custom mobile web application to process in-person payments using Square hardware.</p> </article> <div class="onebox-metadata"> </div> <div style="clear: both"></div> </aside> <aside class="onebox allowlistedgeneric" data-onebox-src="https://developer.squareup.com/docs/square-get-started"> <header class="source"> <img src="https://global.discourse-cdn.com/square/original/2X/f/f587a741c8dbedfcb8cb680873adb3eb6643d1de.png" class="site-icon" data-dominant-color="000000" width="32" height="32"> <a href="https://developer.squareup.com/docs/square-get-started" target="_blank" rel="noopener">Square Developer</a> </header> <article class="onebox-body"> <h3><a href="https://developer.squareup.com/docs/square-get-started" target="_blank" rel="noopener">Get Started</a></h3> <p>Learn how to quickly sign up for a Square account and test APIs.</p> </article> <div class="onebox-metadata"> </div> <div style="clear: both"></div> </aside> <details> <summary> Additional Documentation</summary> <p><a href="https://developer.squareup.com/docs/orders-api/quick-start/start">https://developer.squareup.com/docs/orders-api/quick-start/start</a><br> <a href="https://developer.squareup.com/docs/get-started" class="inline-onebox">Get Started</a><br> <a href="https://developer.squareup.com/docs/in-app-payments-sdk/quick-start/start" class="inline-onebox">In-App Payments SDK Quickstart</a></p> </details> <p>If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.<br> Otherwise one of our Developer Advocates will provide additional assistance shortly.</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_3' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://developer.squareup.com/forums/u/Square-Dev-AI'><span itemprop='name'>Square-Dev-AI</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2024-11-25T17:17:15Z' class='post-time'> November 25, 2024, 5:17pm </time> <meta itemprop='dateModified' content='2024-11-25T17:17:15Z'> <span itemprop='position'>3</span> </span> </div> <div class='post' itemprop='text'> <p>The Square.js file is optimized for performance and there isn鈥檛 a setting to further speed it up. The file size and load time are necessary to ensure secure and reliable payment processing. The load time can vary based on several factors including the user鈥檚 internet speed and the performance of their device. It鈥檚 important to note that the load time of Square.js does not block the rendering of your webpage, so users can still interact with your site while the file is loading.</p> <p>To improve the overall load time of your webpage, you could consider techniques such as lazy loading, where you defer the initialization of Square payment form until it鈥檚 needed (for example, when the user navigates to the checkout page), or asynchronously loading the script so it doesn鈥檛 block the rendering of the rest of your webpage.</p> <p>However, it鈥檚 important to ensure that any optimization techniques you use do not compromise the security and functionality of the payment process.</p> <p><em>This answer was reviewed by <a class="mention" href="/forums/u/bryan-square">@Bryan-Square</a>.</em></p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_4' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://developer.squareup.com/forums/u/osd3'><span itemprop='name'>osd3</span></a> </span> <link itemprop="image" href="https://global.discourse-cdn.com/square/original/2X/f/fe4d03160fb50831e24c417fcd1f13256045dfb9.png"> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2024-11-25T20:58:36Z' class='post-time'> November 25, 2024, 8:58pm </time> <meta itemprop='dateModified' content='2024-11-25T20:58:36Z'> <span itemprop='position'>4</span> </span> </div> <div class='post' itemprop='text'> <aside class="quote group-squares" data-username="Square-Dev-AI" data-post="3" data-topic="19802"> <div class="title"> <div class="quote-controls"></div> <img loading="lazy" alt="" width="24" height="24" src="https://sea1.discourse-cdn.com/square/forums/user_avatar/developer.squareup.com/square-dev-ai/48/2513_2.png" class="avatar"> Square-Dev-AI:</div> <blockquote> <p>The Square.js file is optimized for performance and there isn鈥檛 a setting to further speed it up.</p> </blockquote> </aside> <p>There is one thing you can do to help create a better experience. <strong>Return the content-length header in the compressed version</strong> of your square.js file so I can implement a progress bar to show people when my shop begins to load.</p> <p>These are the HTTP headers for the compressed version that doesn鈥檛 show content length:</p> <p><div class="lightbox-wrapper"><a class="lightbox" href="https://global.discourse-cdn.com/square/original/2X/f/fe4d03160fb50831e24c417fcd1f13256045dfb9.png" data-download-href="/forums/uploads/short-url/AhEh3kUPB40SNwa9szhhswALe9b.png?dl=1" title="compressed square.js" rel="noopener nofollow ugc"><img src="https://global.discourse-cdn.com/square/original/2X/f/fe4d03160fb50831e24c417fcd1f13256045dfb9.png" alt="compressed square.js" data-base62-sha1="AhEh3kUPB40SNwa9szhhswALe9b" width="569" height="456"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">compressed square.js</span><span class="informations">569脳456 33.3 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p> <p>These are the HTTP headers for the uncompressed version that shows content length on the 3rd line of output:</p> <p><div class="lightbox-wrapper"><a class="lightbox" href="https://global.discourse-cdn.com/square/original/2X/d/d0e62e3fbe3b14753b968bca476bcf277ad2e1b7.png" data-download-href="/forums/uploads/short-url/tO0tmGsYKIe9y8GenKYpIL2S5n1.png?dl=1" title="uncompressed square.js" rel="noopener nofollow ugc"><img src="https://global.discourse-cdn.com/square/original/2X/d/d0e62e3fbe3b14753b968bca476bcf277ad2e1b7.png" alt="uncompressed square.js" data-base62-sha1="tO0tmGsYKIe9y8GenKYpIL2S5n1" width="565" height="456"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">uncompressed square.js</span><span class="informations">565脳456 33.1 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p> <p>For reference the script I refer to is this:<br> <a href="https://web.squarecdn.com/v1/square.js" class="onebox" target="_blank" rel="noopener nofollow ugc">https://web.squarecdn.com/v1/square.js</a></p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> <div id='post_5' itemprop='comment' itemscope itemtype='http://schema.org/Comment' class='topic-body crawler-post'> <div class='crawler-post-meta'> <span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person"> <a itemprop="url" rel='nofollow' href='https://developer.squareup.com/forums/u/Lance-Square'><span itemprop='name'>Lance-Square</span></a> </span> <span class="crawler-post-infos"> <time itemprop='datePublished' datetime='2024-11-26T17:54:05Z' class='post-time'> November 26, 2024, 5:54pm </time> <meta itemprop='dateModified' content='2024-11-26T17:54:05Z'> <span itemprop='position'>5</span> </span> </div> <div class='post' itemprop='text'> <p>That would be nice for the developer experience.</p> <p>Unfortunately, content-length header is a feature request. I鈥檒l go ahead and pass this along as a feature request. It鈥檚 a good ask.</p> </div> <div itemprop="interactionStatistic" itemscope itemtype="http://schema.org/InteractionCounter"> <meta itemprop="interactionType" content="http://schema.org/LikeAction"/> <meta itemprop="userInteractionCount" content="0" /> <span class='post-likes'></span> </div> </div> </div> <div id="related-topics" class="more-topics__list " role="complementary" aria-labelledby="related-topics-title"> <h3 id="related-topics-title" class="more-topics__list-title"> Related topics </h3> <div class="topic-list-container" itemscope itemtype='http://schema.org/ItemList'> <meta itemprop='itemListOrder' content='http://schema.org/ItemListOrderDescending'> <table class='topic-list'> <thead> <tr> <th>Topic</th> <th></th> <th class="replies">Replies</th> <th class="views">Views</th> <th>Activity</th> </tr> </thead> <tbody> <tr class="topic-list-item" id="topic-list-item-18386"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='1'> <span class="link-top-line"> <a itemprop='url' href='https://developer.squareup.com/forums/t/square-js-loading-with-progress-bar/18386' class='title raw-link raw-topic-link'>Square.js loading with progress bar</a> </span> <div class="link-bottom-line"> <a href='/forums/c/feature-requests/8' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #08e5f2'></span> <span class='badge-category clear-badge'> <span class='category-name'>Feature Requests</span> </span> </a> <div class="discourse-tags"> <a href='https://developer.squareup.com/forums/tag/sdk' class='discourse-tag'>sdk</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>1</span> </td> <td class="views"> <span class='views' title='views'>17</span> </td> <td> August 21, 2024 </td> </tr> <tr class="topic-list-item" id="topic-list-item-20379"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='2'> <span class="link-top-line"> <a itemprop='url' href='https://developer.squareup.com/forums/t/enabling-square-for-slow-speed-connections/20379' class='title raw-link raw-topic-link'>Enabling square for slow-speed connections</a> </span> <div class="link-bottom-line"> <a href='/forums/c/questions/7' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #006BE6'></span> <span class='badge-category clear-badge'> <span class='category-name'>Questions</span> </span> </a> <div class="discourse-tags"> <a href='https://developer.squareup.com/forums/tag/web-payments-sdk' class='discourse-tag'>web-payments-sdk</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>3</span> </td> <td class="views"> <span class='views' title='views'>21</span> </td> <td> December 31, 2024 </td> </tr> <tr class="topic-list-item" id="topic-list-item-15611"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='3'> <span class="link-top-line"> <a itemprop='url' href='https://developer.squareup.com/forums/t/payments-api-web-server-timeout/15611' class='title raw-link raw-topic-link'>Payments API Web Server Timeout</a> </span> <div class="link-bottom-line"> <a href='/forums/c/questions/7' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #006BE6'></span> <span class='badge-category clear-badge'> <span class='category-name'>Questions</span> </span> </a> <div class="discourse-tags"> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>7</span> </td> <td class="views"> <span class='views' title='views'>216</span> </td> <td> May 9, 2024 </td> </tr> <tr class="topic-list-item" id="topic-list-item-19993"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='4'> <span class="link-top-line"> <a itemprop='url' href='https://developer.squareup.com/forums/t/customers-cannot-complete-payment-because-tokenize-stalls-in-some-environments/19993' class='title raw-link raw-topic-link'>Customers cannot complete payment because tokenize() stalls in some environments</a> </span> <div class="link-bottom-line"> <a href='/forums/c/questions/7' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #006BE6'></span> <span class='badge-category clear-badge'> <span class='category-name'>Questions</span> </span> </a> <div class="discourse-tags"> <a href='https://developer.squareup.com/forums/tag/payments-api' class='discourse-tag'>payments-api</a> , <a href='https://developer.squareup.com/forums/tag/web-payments-sdk' class='discourse-tag'>web-payments-sdk</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>12</span> </td> <td class="views"> <span class='views' title='views'>88</span> </td> <td> December 19, 2024 </td> </tr> <tr class="topic-list-item" id="topic-list-item-1638"> <td class="main-link" itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'> <meta itemprop='position' content='5'> <span class="link-top-line"> <a itemprop='url' href='https://developer.squareup.com/forums/t/terminalapi-create-checkout-delay/1638' class='title raw-link raw-topic-link'>TerminalApi - Create Checkout delay</a> </span> <div class="link-bottom-line"> <a href='/forums/c/questions/7' class='badge-wrapper bullet'> <span class='badge-category-bg' style='background-color: #006BE6'></span> <span class='badge-category clear-badge'> <span class='category-name'>Questions</span> </span> </a> <div class="discourse-tags"> <a href='https://developer.squareup.com/forums/tag/terminal-api' class='discourse-tag'>terminal-api</a> </div> </div> </td> <td class="replies"> <span class='posts' title='posts'>1</span> </td> <td class="views"> <span class='views' title='views'>1048</span> </td> <td> January 20, 2021 </td> </tr> </tbody> </table> </div> </div> </div> <footer class="container wrap"> <nav class='crawler-nav'> <ul> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/' itemprop="url">Home </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/categories' itemprop="url">Categories </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='/forums/guidelines' itemprop="url">Guidelines </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://squareup.com/legal/general/ua' itemprop="url">Terms of Service </a> </span> </li> <li itemscope itemtype='http://schema.org/SiteNavigationElement'> <span itemprop='name'> <a href='https://squareup.com/privacy' itemprop="url">Privacy Policy </a> </span> </li> </ul> </nav> <p class='powered-by-link'>Powered by <a href="https://www.discourse.org">Discourse</a>, best viewed with JavaScript enabled</p> </footer> <div class="buorg"><div>Unfortunately, <a href="https://www.discourse.org/faq/#browser">your browser is unsupported</a>. Please <a href="https://browsehappy.com">switch to a supported browser</a> to view rich content, log in and reply.</div></div> </body> </html>