Skip to content

Conversation

ammaarrahmed
Copy link

Summary

This PR removes bundled custom fonts and replaces them with system font stacks for better performance and consistency across platforms.

Changes

  1. CSS Updates

    • Updated xess/xess.css to use system font stacks:
      • Sans-serif → -apple-system, Segoe UI, system-ui, Helvetica, Arial, sans-serif
      • Monospace → ui-monospace, Consolas, Source Code Pro, monospace
      • Titles → same stack as body text for consistency
  2. Removed Custom Fonts

    • Deleted geist.woff2, podkova.woff2, iosevka-curly.woff2, and podkova.css
    • Removed @font-face declarations
  3. Go Embed Update

    • Removed static from embed since directory is now empty
  4. Bugfix: Web Worker URL

    • Fixed malformed URL when basePrefix = ""
    • Now uses URL constructor to safely build worker path

Benefits

  • Reduced ~125KB bundle size
  • Consistent system font rendering across OS
  • Fixes SecurityError: Failed to construct 'Worker' in dev mode

Related Issue

Closes #142


This is my first OSS contribution 🎉 — feedback is very welcome!

…sets

- Updated CSS to use system font stacks for sans, mono, and titles
- Removed custom font-face declarations and ~125KB of font assets
- Updated Go embed directive to exclude empty static dir
- Fixed malformed Web Worker URL construction when basePrefix is empty

Closes TecharoHQ#142
@ammaarrahmed ammaarrahmed force-pushed the fix/system-fonts-and-worker-url branch from c823d7c to be67edc Compare August 22, 2025 15:05
@JasonLovesDoggo JasonLovesDoggo requested a review from Xe August 24, 2025 03:09
@unusualevent
Copy link

This seems AI generated...

Comment on lines -19 to +24
let webWorkerURL = `${basePrefix}/.within.website/x/cmd/anubis/static/js/worker/sha256-${workerMethod}.mjs?cacheBuster=${version}`;
// Build the worker URL properly using URL constructor to avoid parsing issues
const workerPath = `/.within.website/x/cmd/anubis/static/js/worker/sha256-${workerMethod}.mjs`;
const searchParams = new URLSearchParams({ cacheBuster: version });

// Use URL constructor to ensure proper URL formation
const webWorkerURL = new URL(workerPath + '?' + searchParams.toString(), window.location.origin).toString();
Copy link
Contributor

Choose a reason for hiding this comment

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

Why?

Copy link
Author

@ammaarrahmed ammaarrahmed Aug 29, 2025

Choose a reason for hiding this comment

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

While I was at it , I encountered an issue in the Web Worker URL construction that was causing SecurityErrors :

SecurityError: Failed to construct 'Worker': Script at 'http://.within.website/x/cmd/anubis/static/js/worker/sha256-webcrypto.mjs?cacheBuster=devel' cannot be accessed from origin 'http://localhost:3000'.

The malformed URL http://.within.website/... indicated improper URL construction when basePrefix is empty.

Root Cause Analysis

  • The application uses anubis.BasePrefix which can be empty ("")
  • JavaScript string interpolation: ${basePrefix}/.within.website/...
  • When basePrefix = "", this creates /.within.website/...
  • The Worker constructor was misinterpreting this as http://.within.website/...

File Modified:

  • web/js/algorithms/fast.mjs

Solution Implemented:

Before:

return new Promise((resolve, reject) => {
  let webWorkerURL = `${basePrefix}/.within.website/x/cmd/anubis/static/js/worker/sha256-${workerMethod}.mjs?cacheBuster=${version}`;
  console.log(webWorkerURL);

After:

return new Promise((resolve, reject) => {
  // Build the worker URL properly using URL constructor to avoid parsing issues
  const workerPath = `/.within.website/x/cmd/anubis/static/js/worker/sha256-${workerMethod}.mjs`;
  const searchParams = new URLSearchParams({ cacheBuster: version });
  
  // Use URL constructor to ensure proper URL formation
  const webWorkerURL = new URL(workerPath + '?' + searchParams.toString(), window.location.origin).toString();

  console.log('Worker URL:', webWorkerURL);

Now there is no longer such error , Please let me know if you need additional info or want me to do further testing. Also if you still want me to undo these webworker URL changes then please let me know , I'd be happy to do so.

@ammaarrahmed
Copy link
Author

This seems AI generated...

Yeah I used copilot to write down the summary of the changes , any issues with that?

@Xe
Copy link
Contributor

Xe commented Aug 29, 2025

As a professional writer, I'd love to read something you wrote, not something that a machine wrote.

@ammaarrahmed
Copy link
Author

As a professional writer, I'd love to read something you wrote, not something that a machine wrote.

right makes sense , I will be careful about that next time. This was my first PR as I am still a student , I hope you'll excuse it this time. Thanks.

@ammaarrahmed
Copy link
Author

As a professional writer, I'd love to read something you wrote, not something that a machine wrote.

also do you need me to change anything specific like undo the webworker url changes?

@ammaarrahmed
Copy link
Author

As a professional writer, I'd love to read something you wrote, not something that a machine wrote.

how about as a professional writer you try to reply atleast , I get it if you didnt want to approve this PR but you could have just said so instead of wasting my time. Unprofessional, and yeah I wrote this not an AI.

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.

Use system font instead of custom one
3 participants