Browse Source
This commit introduces a resilient fallback mechanism for all third-party JavaScript libraries, ensuring the application remains functional even if local files are unavailable. Previously, the application would fail to load if any of the JavaScript files in the `/vendor` directory were missing or failed to load. This change implements an "offline-first, online-fallback" strategy. The implementation checks for the existence of each library's global object (e.g., `window.p5`) immediately after attempting to load the local script. If the object is not found, indicating a load failure, a new `<script>` tag is dynamically and asynchronously created and appended to the document's head. This new script then loads the library from its public CDN. This approach was chosen after evaluating two other methods: 1. The `<script onerror="...">` attribute was found to be unreliable, as local development servers often return a 404 HTML page (with a `200 OK` status and `text/html` MIME type) instead of a network error, which does not trigger the `onerror` event. 2. Using `document.write()` was functional but generated numerous parser-blocking warnings in the browser console and is considered a poor practice for performance. The final implementation is non-blocking and follows modern web development best practices, making the application significantly more resilient for both development and production environments.refactor/modularize
8 changed files with 121666 additions and 7 deletions
1
steps/vendor/ag-grid-community.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
14
steps/vendor/chart.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
8
steps/vendor/clarinet.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
5
steps/vendor/oboe.min.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
121501
steps/vendor/p5.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
83
steps/vendor/tailwind-cdn.js
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
Loading…
Reference in new issue