Skip to content

Conversation

@jawinn
Copy link
Contributor

@jawinn jawinn commented Nov 18, 2025

Makes page speed request to the serverless function URL, and logs results to the console. Adds a PageSpeedService script. Includes both console and a UI facing error message on failure. Updates "Analyze" button so it makes the the page speed fetch request to the testing URL, and enables/disables the button with some testing in progress text.

Validation:

  • Analyze button shows "Test: Making request..." text.
  • Request completes and logs to console.
  • if you want to test the error message, modify the proxyRequestUrl to be a bad URL

BLDL-9

@github-actions
Copy link

github-actions bot commented Nov 18, 2025

📦 Extension packages built successfully!

Download your Chrome and Firefox extension packages

Copy link
Member

@jonoliver jonoliver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Josh, works as expected! Just a few suggestions.

*/
export const makePageSpeedAPIRequest = async (urlToMeasure, logDebug = false) => {
// Proxy URL using serverless function that will return data.
const proxyRequestUrl = `https://carbon-calculator-proxy.netlify.app/.netlify/functions/page-speed?url=${encodeURIComponent(urlToMeasure)}`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should extract the API url to make it more easily configurable. It might ultimately make sense to use an ENV variable that gets injected to a hard-coded variable at build time, so that we could toggle between testing environments for the API. But for now, I'd say let's at least extract it to a PAGE_SPEED_API_URL const at the top of this file:

const PAGE_SPEED_API_URL = "https://carbon-calculator-proxy.netlify.app/.netlify/functions/page-speed";

await extensionManager.openPanel('results');
// For now, just show a simple message within the button.
analyzeBtn.disabled = true;
analyzeBtn.textContent = 'Test: Making request and logging to console...';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is temporary, but we should probably make the messaging a little more finalized for the user. How about: "Analyzing page..."

}

// Reset button back to usable state.
analyzeBtn.textContent = 'Analyze This Page';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This text is different from the original button text, which is "Analyze this website". I think your text actually makes more sense, since we're analyzing a specific page. I vote that we:

  • Update the original text in welcome.html to "Analyze this page"
  • Instead of repeating the text string here, capture the original message above, before it changes: const analyzeBtnText = analyzeBtn.textContent;
  • Use the variable to reset the text here in place of the hard-coded string: analyzeBtn.textContent = analyzeBtnText;

Basic page speed service function setup with debug logging.

Update analyze button so it makes the the page speed fetch request to
the testing URL. Updates async handling of the button and includes
both console and a UI facing error message.
@jawinn jawinn force-pushed the feat--page-speed-implementation branch from 0d4caee to b3b5b30 Compare December 2, 2025 18:31
@jawinn
Copy link
Contributor Author

jawinn commented Dec 2, 2025

@jonoliver Thanks, I've updated with those suggestions, and rebased with main.

@jawinn jawinn requested a review from jonoliver December 2, 2025 18:33
@jonoliver jonoliver merged commit e5599e6 into main Dec 2, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants