You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+31-48Lines changed: 31 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -318,64 +318,47 @@ var output = translate.prettyPrintLegacyAssemblyJSON(assemblyJSON, sourceCode)
318
318
319
319
## Browser Usage
320
320
321
-
Add the version of `solc` you want to use into `index.html`:
321
+
Compilation is generally a long-running and resource intensive task that cannot reasonably be performed in the main thread of the browser.
322
+
Some browsers even dissallow synchronous compilation on the main thread if the module is larger than 4KB.
323
+
Thus, the only supported way to use `solc` in a web browser is through a [web worker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers).
This will load `solc` into the global variable `window.Module`.
333
-
Alternatively, use `soljson-latest.js` as `{{ SOLC_VERSION }}.js` in the code snippet above to load the latest version.
327
+
Web Workers allow you to run javascript in the background in the browser, letting the browser's main thread free to do whatever it needs to do.
328
+
Please, see the minimal example of how to use `solc` with web workers below or check out this [repository](https://github.com/r0qs/solcjs-webworker-example) for a full demo.
334
329
335
-
It is recommended that you check the integrity of the resource being fetched before using it in your application.
336
-
For that, you can use the [Subresource Integrity (SRI)](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) feature.
337
-
Adding SRI configuration to your HTML script tag ensures that the resource will only be loaded by the browser if the cryptographic hashes match.
330
+
* index.html
331
+
```html
332
+
<!DOCTYPE html>
333
+
<html>
338
334
339
-
You can generate the SRI hash yourself based on the base64-encoded version of the sha256 hash of the release.
340
-
For example, after downloading version `v0.8.16+commit.07a7930e`, run:
This will result in two global variables, `window.soljsonReleases` listing all releases and `window.soljsonSources` listing all nightly builds and releases.
0 commit comments