-
Notifications
You must be signed in to change notification settings - Fork 49
Init 3rd-party-optimizer plugin #392
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
Merged
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
4d019c4
Init 3rd-party-optimizer plugin
kurtextrem 8ee1690
Allow custom vite config
kurtextrem 6b721ec
bump yarn / yarn dedupe
kurtextrem 2cbb1eb
fix lint errors
kurtextrem f71f187
Add final URL
kurtextrem 777fafc
Add HTMLFormElement override
kurtextrem c181eba
Add MutationObserver for monitoring `dataLayer`
kurtextrem 34cda89
use postTask if possible, add performance timeline entries
kurtextrem e03996a
Fix `shouldWaitForLoad`
kurtextrem fd409e4
Make sure events are only handled once
kurtextrem 705455e
update lockfile after rebase
kurtextrem 9f0fe3d
fix spacings
kurtextrem 5993f31
Update package.json
kurtextrem 2a06dca
upgrade to yarn 4.9.4
kurtextrem f52cce3
use es2021
kurtextrem 3d8ba57
add globals.d.ts
kurtextrem 204088f
Convert to Tailwind
kurtextrem 3edfdc6
add framer-plugin & framer/vite-config to package.json
kurtextrem 1de8140
fix items-center
kurtextrem 0221f4e
add explicit case
kurtextrem 429a5a0
restore framer-plugin@3.3.2
kurtextrem e0cf874
Revert "restore framer-plugin@3.3.2"
kurtextrem 2be862b
bump all plugins up to framer-plugins@3.5.2
kurtextrem 8ff363d
Ensure we call the original if the proto chain returns undefined
kurtextrem 4328847
Document `scrollend` and `resize` listeners
kurtextrem 4891bcf
Add `isInputPending` check
kurtextrem 445aa1a
Ensure we always call the underlying method & retain `this`
kurtextrem 3c76342
v1.0.1
kurtextrem 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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+158 KB
...obox-npm-3.13.1-6b67ae6981-a54d90e106.zip → ...obox-npm-3.13.2-8f78d172f7-9f3dd28acd.zip
Binary file not shown.
Binary file renamed
BIN
+22.2 KB
...alog-npm-3.5.29-3778666ad1-100a265ddc.zip → ...alog-npm-3.5.30-4b68cd48fd-a95ded7450.zip
Binary file not shown.
Binary file renamed
BIN
+493 KB
...-dnd-npm-3.11.1-db4053056b-086e151e0e.zip → ...-dnd-npm-3.11.2-9cfae27875-33957ac694.zip
Binary file not shown.
Binary file renamed
BIN
+175 KB
...menu-npm-3.19.1-7f2295f449-09c6295086.zip → ...menu-npm-3.19.2-0c5fb1350e-ce2bc6747a.zip
Binary file not shown.
Binary file renamed
BIN
+285 KB
...lays-npm-3.29.0-933b36c7f4-2d12c93d2c.zip → ...lays-npm-3.29.1-666fcb1ef5-78e0d606f9.zip
Binary file not shown.
Binary file renamed
BIN
+46.6 KB
...lect-npm-3.16.1-7dc026c1be-37075d42a8.zip → ...lect-npm-3.16.2-5a2fc9ee67-2c19e1dd60.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+195 KB
...aria-npm-3.43.0-d06e202fb5-4ddd9af8d7.zip → ...aria-npm-3.43.1-9f38b5f98c-3b85dcd09d.zip
Binary file not shown.
716 changes: 358 additions & 358 deletions
716
.yarn/releases/yarn-4.9.2.cjs → .yarn/releases/yarn-4.9.4.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # 3rd-Party Optimizer | ||
|
|
||
| This plugin installs a snippet that optimizes how 3rd-party analytics scripts interact with the main-thread, to improve Core Web Vitals (INP). | ||
|
|
||
| See also [yieldGTMCalls.md](./yieldGTMCalls.md) for detailed docs. | ||
|
|
||
| ## Quickstart | ||
|
|
||
| First, run the development server: | ||
|
|
||
| ```bash | ||
| npm run dev | ||
| # or | ||
| yarn dev | ||
| # or | ||
| pnpm dev | ||
| # or | ||
| bun dev | ||
| ``` | ||
|
|
||
| Learn more: https://www.framer.com/developers/plugins/introduction |
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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "id": "d84d6c", | ||
| "name": "3rd-Party Optimizer", | ||
| "modes": ["canvas"], | ||
| "icon": "/icon.svg" | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href="/icon.svg" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| <title>3rd-Party Optimizer</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script type="module" src="/src/main.tsx"></script> | ||
| </body> | ||
| </html> | ||
|
|
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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| { | ||
| "name": "3rd-party-optimizer", | ||
| "private": true, | ||
| "version": "1.0.1", | ||
| "type": "module", | ||
| "scripts": { | ||
| "dev": "VITE_CONFIG_PATH=$(pwd)/vite.config.ts run g:dev", | ||
| "build": "VITE_CONFIG_PATH=$(pwd)/vite.config.ts run g:build", | ||
| "check-biome": "run g:check-biome", | ||
| "check-eslint": "run g:check-eslint", | ||
| "preview": "VITE_CONFIG_PATH=$(pwd)/vite.config.ts run g:preview", | ||
| "pack": "npx framer-plugin-tools@latest pack", | ||
| "check-typescript": "run g:check-typescript" | ||
| }, | ||
| "dependencies": { | ||
| "framer-plugin": "^3.5.2", | ||
| "react": "^18.2", | ||
| "react-dom": "^18.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@framer/vite-config": "workspace:*", | ||
| "@types/node": "^22", | ||
| "@types/react": "^18.2", | ||
| "@types/react-dom": "^18.2", | ||
| "esbuild": "^0.25.9" | ||
| } | ||
| } | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| @import "tailwindcss"; | ||
| @import "framer-plugin/framer.css" layer(base); | ||
|
|
||
| @layer base { | ||
| input, | ||
| button, | ||
| textarea, | ||
| select { | ||
| padding: initial; | ||
| } | ||
|
|
||
| p { | ||
| color: var(--framer-color-text-tertiary); | ||
| text-align: center; | ||
| } | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| import type { CustomCode } from "framer-plugin" | ||
| import { framer } from "framer-plugin" | ||
| import { useLayoutEffect, useSyncExternalStore } from "react" | ||
| import "./App.css" | ||
|
|
||
| import scriptSource from "virtual:yield-gtm-calls" | ||
| import warning from "./warning.svg?url" | ||
|
|
||
| let currentCustomCode: CustomCode | null = null | ||
|
|
||
| const subscribe = (callback: () => void) => { | ||
| return framer.subscribeToCustomCode(customCode => { | ||
| currentCustomCode = customCode | ||
| callback() | ||
| }) | ||
| } | ||
| const getSnapshot = () => currentCustomCode | ||
|
|
||
| export function App() { | ||
| const customCode = useSyncExternalStore(subscribe, getSnapshot) | ||
|
|
||
| const scriptAdded = !!customCode?.headStart.html | ||
| const scriptOutdated = scriptAdded && customCode.headStart.html !== scriptSource | ||
| const toggleScript = (update?: boolean) => { | ||
| void framer.setCustomCode({ | ||
| html: scriptAdded && !update ? "" : scriptSource, | ||
| location: "headStart", | ||
| }) | ||
| } | ||
|
|
||
| useLayoutEffect(() => { | ||
| let height = 137 | ||
| if (customCode?.headStart.disabled) { | ||
| height += 10 | ||
| } | ||
| if (scriptOutdated) { | ||
| height += 60 | ||
| } | ||
|
|
||
| void framer.showUI({ | ||
| position: "top right", | ||
| width: 260, | ||
| height, | ||
| }) | ||
| }, [customCode?.headStart.disabled, scriptOutdated]) | ||
|
|
||
| return ( | ||
| <main className="flex flex-col gap-[15px] | items-start | h-full | p-[15px] pt-0"> | ||
| <div className="framer-divider" /> | ||
|
|
||
| {!customCode?.headStart.disabled && ( | ||
| <p> | ||
| Add a script to your custom HTML to improve site performance when using 3rd-party tracking scripts.{" "} | ||
| <a href="https://www.framer.com/marketplace/plugins/3rd-party-optimizer/" target="_blank"> | ||
| Learn more | ||
| </a> | ||
| </p> | ||
| )} | ||
|
|
||
| {customCode?.headStart.disabled && ( | ||
| <div className="flex flex-col gap-[10px] | justify-center items-center"> | ||
| <div className="flex | justify-center | w-full | py-[4px]"> | ||
| <img src={warning} alt="Warning" /> | ||
| </div> | ||
| <p> | ||
| The script is disabled. Please go to | ||
| <br /> Site Settings → General and enable it. | ||
| </p> | ||
| </div> | ||
| )} | ||
|
|
||
| {scriptOutdated && ( | ||
| <> | ||
| <div className="framer-divider" /> | ||
| <div className="flex | justify-between items-center | w-full"> | ||
| <p>New script version available</p> | ||
| <button | ||
| className="framer-button-primary bg-[var(--framer-color-tint-dimmed)] text-[var(--framer-color-tint)] hover:bg-[var(--framer-color-tint-dimmed)] focus:bg-[var(--framer-color-tint-dimmed)] | rounded-[6px] | text-[10px] font-500 | w-[46px] h-[20px]" | ||
| onClick={toggleScript.bind(null, true)} | ||
| > | ||
| Update | ||
| </button> | ||
| </div> | ||
| <div className="framer-divider" /> | ||
| </> | ||
| )} | ||
|
|
||
| <button | ||
| className={`framer-button-secondary${scriptOutdated ? "" : " mt-[5px]"}`} | ||
| onClick={toggleScript.bind(null, false)} | ||
| > | ||
| {scriptAdded ? "Remove Script" : "Add Script"} | ||
| </button> | ||
| </main> | ||
| ) | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| declare module "virtual:yield-gtm-calls" { | ||
| const content: string | ||
| export default content | ||
| } |
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 |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import React from "react" | ||
| import ReactDOM from "react-dom/client" | ||
| import { App } from "./App.tsx" | ||
|
|
||
| const root = document.getElementById("root") | ||
| if (!root) throw new Error("Root element not found") | ||
|
|
||
| ReactDOM.createRoot(root).render( | ||
| <React.StrictMode> | ||
| <App /> | ||
| </React.StrictMode> | ||
| ) |
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| /// <reference types="vite/client" /> | ||
|
|
||
| interface ViteTypeOptions { | ||
| strictImportMetaEnv: unknown | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.