-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Download page: show gzipped size #6067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
patmmccann
wants to merge
7
commits into
prebid:master
Choose a base branch
from
patmmccann:codex/add-gzip-package-size-to-download-page
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0ced8a9
feat(download): show gzipped size
patmmccann c3ccde9
Merge branch 'master' into codex/add-gzip-package-size-to-download-page
patmmccann bc0200d
Merge branch 'master' into codex/add-gzip-package-size-to-download-page
patmmccann 68beb13
Add config download support and gz size display
patmmccann 188dc89
Merge pull request #19 from patmmccann/codex/clean-up-merge-conflicts
patmmccann 4af5a93
Merge branch 'master' into codex/add-gzip-package-size-to-download-page
patmmccann 67cf866
Merge branch 'master' into codex/add-gzip-package-size-to-download-page
patmmccann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,15 @@ | |
| } | ||
| } | ||
|
|
||
| function triggerDownload(blob, filename) { | ||
| var link = document.createElement("a"); | ||
| link.href = window.URL.createObjectURL(blob); | ||
| link.download = filename; | ||
| document.body.appendChild(link); | ||
| link.click(); | ||
| document.body.removeChild(link); | ||
| } | ||
|
|
||
| function submit_download() { | ||
| $('#download-button').html('<i class="glyphicon glyphicon-send"></i> Sending Request...').addClass('disabled'); | ||
|
|
||
|
|
@@ -105,13 +114,20 @@ | |
| if (matches != null && matches[1]) | ||
| filename = matches[1].replace(/['"]/g, ""); | ||
| } | ||
|
|
||
| var jsBlob = new Blob([data], { type: "text/javascript" }); | ||
| var configData = JSON.stringify({ version: form_data.version, modules: form_data.modules }, null, 2); | ||
|
|
||
| triggerDownload(jsBlob, filename); | ||
| triggerDownload(new Blob([configData], { type: "application/json" }), "prebid-config.json"); | ||
|
|
||
| triggerDownload(new Blob([configData], { type: "application/json" }), "prebid-config.json") | ||
| if (window.pako) { | ||
| try { | ||
| var gz = pako.gzip(data); | ||
| var kb = (gz.length / 1024).toFixed(1); | ||
| document.getElementById('package-size').innerText = 'Estimated gzipped size: ' + kb + ' kB'; | ||
| } catch(e) { | ||
| console.log('pako gzip failed', e); | ||
| } | ||
| } | ||
|
Comment on lines
+122
to
+130
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doing this after the download has a weird UX. I understand that in order to calculate the gzipped size, we first need to have the file itself. Still it's so tiny at the bottom, I could hardly find it. We can add this, but not sure of the value it adds 😁 |
||
| if (form_data["removedModules"].length > 0) { | ||
| alert( | ||
| "The following modules were removed from your download because they aren't present in Prebid.js version " + | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function already exists and just got copy and pasted to the top