今日已更新 246 条资讯 | 累计 21112 条内容
关于我们

标签:#webdev

找到 1571 篇相关文章

AI 资讯

How I Built Pakistan's Stock Market Education Platform as a Solo Trader-Developer

I am a full time trader and part time developer based in Karachi, Pakistan. A year ago I sat down to research how to properly compare brokers on the Pakistan Stock Exchange. Three hours later I had 11 browser tabs open, two of which had broken links, one had data from 2019, and none of them had everything I needed in one place. So I built PSX Pulse. What PSX Pulse Is PSX Pulse is a free stock market education platform for Pakistani retail investors. Everything a beginner needs to start investing in Pakistan's stock market — in one place. What is live right now: 35 verified SECP-licensed brokers with full contact details Complete mutual funds directory across 15 AMCs DCA calculator with realistic return scenarios 30-day beginner learning path Islamic investing guide PSX sector guide covering 12 sectors IPO tracker 100-term searchable glossary Weekly market recap every Friday All free. No login required. Live at: https://psxpulse.xwen.com.pk/ The Stack React + Tailwind CSS for the frontend. Vercel for hosting — free tier handles everything comfortably. No backend for most features — localStorage and static data keeps it fast and simple. Newsletter handled via a serverless Vercel function writing to a private GitHub CSV. What I Learned Building This Solo 1. The information gap in emerging markets is enormous Pakistani investors are not underserved because nobody cares. They are underserved because nobody with the technical skills to build tools also has the market knowledge to know what those tools should do. Being both a trader and a developer turned out to be the actual unfair advantage. 2. Free tools beat content for SEO My DCA calculator and broker directory pages get more consistent Google clicks than any article I have written. Tools solve a specific search intent that AI overviews do not replace — people still need to interact with a calculator, not just read about one. 3. Building in public is uncomfortable but worth it Sharing what you are building before it i

2026-06-04 原文 →
AI 资讯

How I built a lightning-fast Game Sens Converter in Vanilla JS

As a developer who frequently switches between competitive FPS titles like CS2 and Valorant, re-tuning mouse sensitivity is always a hassle. I wanted a fast, ad-free tool to translate my aim perfectly across titles, so I built a clean Game Sens Converter . The Approach I built this using 100% Vanilla JS. It’s a simple utility, so there was absolutely no need for a backend or heavy frameworks. It loads instantly and calculates right in the browser. Here is a quick look at the core logic handling the sensitivity conversion multipliers: function convertSensitivity ( gameFrom , gameTo , currentSens ) { // Standardized multipliers relative to CS2 / Source engine const multipliers = { ' cs2 ' : 1 , ' valorant ' : 3.181818 , ' overwatch ' : 0.3 , ' apex ' : 1 }; if ( ! multipliers [ gameFrom ] || ! multipliers [ gameTo ]) return null ; // Convert to base (CS2), then to the target game const baseSens = currentSens * multipliers [ gameFrom ]; const convertedSens = baseSens / multipliers [ gameTo ]; return convertedSens . toFixed ( 3 ); } Try it out You can use the live tool for free here: Game Sens Converter Let me know what your main game is or if you'd add any other FPS titles to the list in the comments!

2026-06-04 原文 →
AI 资讯

If a company serves 2 countries, would you recommend having 2 website portals/landings? And also to hide a country mention from the other country?

Here is the situation of the website. If someone in Canada enters www.example.com they are redirected to www.example.com/ca and ALL the mention of "USA" is hidden and replaced with "Canada"! For example in Canada, instead of people seeing "Home Improvement in the USA and Canada", people in Canada just see "Home improvement in Canada", and vice versa; someone in USA and everywhere other than Canada on the globe does NOT see Canada on the website pages . My question is: Shouldn't a website have unified info and list BOTH USA and Canada, because with current situation someone accessing the homepage in Canada would NOT know that the company can also do Home improvement in the USA and vice versa . Even for AIs, I asked Chatgpt where is the company located and did NOT see Canada. P.S. The only mention of both countries is in the contact page. submitted by /u/RadiantQuests [link] [留言]

2026-06-04 原文 →
AI 资讯

Stop Hardcoding 301s: How I Built a Redirect Engine That Doesn't Break at 2 A.M.

Marketing wants an A/B landing page by Friday. Product wants to gracefully deprecate a legacy API without breaking old mobile clients. Growth wants ten thousand short links, and Ops does not want ten thousand Nginx edits. At some point, a single return 301 in your CDN stops being a configuration problem and becomes a routing product . Someone has to answer, on every HTTP request: Given this host, path, query, and method—where does this visitor go, and with which status code? I built that answer as a pipeline at LinkShift . Not a pile of special cases, but a fixed sequence of steps that runs the exact same way for real visitors and for the tools you use to test rules before rollout. Here is how I designed a deterministic redirect engine, the pipeline that powers it, and the edge cases that kept me up at night so they don't have to keep you up. Why "Usually Works" Is Not Enough A redirect engine fails quietly. The browser follows a broken 302 and nobody files a ticket. The damage shows up days later in analytics: wrong campaign, wrong locale, or an infinite loop that only appears when two rules on the same host point at each other. What I wanted early on was boring, bulletproof reliability: Same inputs → same decision. Two engineers simulating the same request against the same rule set should get the same target URL. Same resolution logic everywhere. Matching and destination resolution must not diverge between the "Test Rule" button in the dashboard and an actual click on a custom domain. Guards before cleverness. Rate limits and access checks run before anyone evaluates a ternary conditional in a destination string. Expressiveness is easy. Ordering is what saves you in production. The Pipeline, Told as a Story Picture a request hitting a hostname. Before the engine asks "which rule wins?", the request walks through a strict corridor of gates. Only then does it enter the rule loop. Gate 1: The Host Has to Exist If the hostname does not resolve to a domain or LinkShift

2026-06-04 原文 →
AI 资讯

AI-Assisted QA Changes the Testing Job, Not the Testing Need

Internal note to the team, we need to improve test coverage and keep shipping, which means we should treat AI as a helper in the workflow, not as a replacement for testing discipline. AI-assisted development changes the shape of our risk. It can produce more code faster, but it also increases the chance that small logic mistakes, brittle selectors, and shallow test cases slip through review. The answer is not to add more manual checking everywhere. The answer is to be more deliberate about what we review, what we automate, and where we let AI help. What changes when AI writes part of the code The first thing that changes is review. When a developer uses AI to draft a feature, a test, or a refactor, the reviewer is no longer only checking intent and style. The reviewer also needs to check whether the generated code matches the product rule, whether it introduced a hidden dependency, and whether it quietly weakened coverage. That does not mean every AI-assisted change deserves extra ceremony. It means our review checklist should shift from "does this look correct" to "what did the model assume, and did we verify those assumptions?" That is especially important for test code, because generated tests often look plausible even when they do not prove much. Coverage should move from volume to signal AI tends to produce more test cases, but more cases are not the same as better coverage. If a generated test suite repeats the same happy path under slightly different names, the team gets a false sense of safety. Coverage should answer a more practical question, where are we most likely to break the user experience, and where will a test actually catch it? For chat and other AI features, prompt-by-prompt manual checks are a trap. They do not scale, and they encourage a habit of eyeballing output instead of verifying behavior. A better pattern is to build assertions around expected properties, create eval sets for representative prompts, and add regression coverage for failure

2026-06-04 原文 →
开发者

How to Build a Browser Tool and Sell It on Gumroad — A Complete Guide

I built 24 browser-based tools. Here is the complete technical guide for building your own and selling PRO licenses on Gumroad. Architecture: One HTML File + GitHub Pages + Gumroad No frameworks, no backend, no monthly costs. One HTML file on GitHub Pages. Gumroad handles payments. The PRO Flow User hits free limit → PRO modal Buy button → Gumroad popup ( window.open , NOT target=_blank ) Payment → Gumroad postMessage with license key message listener catches key Key verified via Gumroad API ( /v2/licenses/verify ) localStorage saves PRO (in try-catch!) Gotchas From 24 Tools postMessage security: Check d.success && d.purchase , never just d.license_key . I had this bug in 17 files. localStorage: Wrap in try-catch . Uncaught throws crash the whole page. CDN scripts: Always <script defer> . Without it, slow CDN blocks rendering. Gumroad publish: curl returns false every time. Use PowerShell. Buy button: Popup connects the page to Gumroad. Redirect breaks postMessage . Packed 5 templates with everything pre-configured: Browser Tools Starter Kit ($19)

2026-06-04 原文 →
开发者

How do you decide a side project is "good enough" to ship instead of polishing forever?

Solo dev here. My biggest bottleneck isn't building, it's deciding when something is done. I keep polishing past the point of diminishing returns and delay shipping for weeks over things no user would notice. For those who ship regularly: - What's your actual "ship it" threshold? - Do you use a hard rule (a deadline, a checklist, a launch date you can't move), or is it a feel thing? - Has shipping earlier than felt comfortable ever hurt you? Trying to build a saner habit around this. How do you draw the line? submitted by /u/IcyButterscotch8351 [link] [留言]

2026-06-04 原文 →
开发者

How to add eslint-disable comments in pug code inside a Vue SFC file?

Hi! I'm having some trouble with eslint-disable comments for HTML elements defined inside a Vue SFC pug template, eslint do not recognize them and keeps throwing warnings. What I've tried so far: Comments inside the pug template, both // and //- <template lang="pug"> // eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -- Standard video player click-to-play-pause behavior video(@click="togglePause" ...) </template> <template lang="pug"> //- eslint-disable-next-line vuejs-accessibility/no-static-element-interactions -- Standard video player click-to-play-pause behavior video(@click="togglePause" ...) </template> My next options are not optimal, but I ran out of ideas: A comment inside the script setup tag (it is placed before the template in the file): <script setup> //eslint-disable vuejs-accessibility/no-static-element-interactions </script> A comment at the very top of the file, before any other code <!-- eslint-disable vuejs-accessibility/no-static-element-interactions --> <script setup></script> <template lang="pug"></template> None of this worked. The only way I managed to make this work was creating overrides in .eslintrc.cjs: // Since eslint-disable comments do not work for HTML elements inside pug we // must include those overrides here. overrides: [ { // Standard video player click-to-pause behavior files: ["src/components/common/SimpleMp4Viewer.vue"], rules: { "vuejs-accessibility/no-static-element-interactions": "off" } } ] Do you know if I am missing something here? The eslint related packages I have in my projects are: dependencies "eslint-config-prettier": "^10.1.8", devDependencies "@rushstack/eslint-patch": "^1.8.0", "@vue/eslint-config-prettier": "^9.0.0", "eslint": "^8.57.0", "eslint-define-config": "^2.1.0", "eslint-plugin-unused-imports": "^4.4.1", "eslint-plugin-vue": "^9.27.0", "eslint-plugin-vue-pug": "^0.6.2", "eslint-plugin-vuejs-accessibility": "^2.5.0", Thank you! submitted by /u/bcons-php-Console [link] [留言]

2026-06-04 原文 →
开发者

Studied how the News Feed works in Instagram and other social media platforms.

One important concept I learned is Fanout, which is basically how posts are distributed to user's feeds. Fanout Push When a user creates a post, the system immediately pushes that post to the feed cache of all followers. This is very fast because the feed is already prepared when users open the app. Fanout Pull Instead of precomputing feeds, the system generates the feed when a user opens the application by fetching posts from accounts they follow. It saves storage and avoids unnecessary work for accounts with huge follower counts. Now real system user Hybrid Approach For normal users with a few hundred followers, Fanout Push works well because the cost is manageable and feed loading is fast. For celebrities like Virat Kohli with 250M+ followers, pushing every post to every follower's feed cache would be extremely expensive. Many followers may not even open the app, so a lot of storage and compute would be wasted. That's why large scale systems often use Fanout Pull (or a hybrid approach) for such accounts. But How Does the Feed Know to Fetch Celebrity Posts? A question I had was: If my normal friends' posts are already present in my feed cache through Fanout Push, how does the system know that it should also fetch posts from celebrity accounts? One possible approach is that the social graph stores metadata about accounts. Celebrity or high follower accounts can be marked differently. When a user opens the app, the Feed Service: Loads the feed generated through Fanout Push. Checks the accounts the user follows in the Social Graph. Identifies celebrity accounts that use Fanout Pull. Fetches their latest posts separately. Merges both results and then applies recommendation algorithms before returning the final feed. Simplified Flow User Creates Post Post Service Store in Database Fanout Service Check Social Graph & User Preferences (blocked users, muted users, close friends, etc.) Create Fanout Tasks Message Queue Fanout Workers (Push or Pull Strategy) I'm still learn

2026-06-04 原文 →
AI 资讯

ACID vs BASE: What Database Guarantees Actually Promise

When people say a database is "ACID-compliant" or "eventually consistent," they are making promises about what happens when things go wrong — concurrent writes, crashes, network failures. ACID and BASE are the two vocabularies for those promises, and knowing the difference tells you what you can and cannot rely on. What ACID guarantees ACID is the contract that traditional transactional databases — PostgreSQL, MySQL/InnoDB, Oracle, SQLite — make about a transaction (a group of operations treated as one unit). The four letters: Atomicity : the whole transaction succeeds or none of it does. If a bank transfer debits one account but the credit fails, the debit is rolled back. There is no half-done state. Consistency : a committed transaction moves the database from one valid state to another, never violating its declared rules (constraints, foreign keys, types). It will not let you, say, leave a foreign key pointing at a row that does not exist. Isolation : concurrent transactions do not step on each other. The result is as if they ran one at a time, even when they actually ran in parallel. (In practice databases offer tunable isolation levels — from "read committed" to "serializable" — trading strictness for speed.) Durability : once the database says "committed," that data survives a crash or power loss. It has been written somewhere persistent, not just held in memory. The payoff is that you can reason about your data simply: after a successful commit, the world is exactly what you asked for. The cost is coordination, which gets expensive when data is spread across many machines. What BASE trades away BASE is the model many distributed and NoSQL systems adopt — think Cassandra, DynamoDB, or Riak — when they need to scale across many nodes and stay up through failures. The acronym is deliberately a chemistry pun on ACID, and it stands for: Basically Available : the system answers requests even during partial failures, possibly with stale or incomplete data rather tha

2026-06-04 原文 →
AI 资讯

How Git Actually Stores Your Code: Blobs, Trees, and Commits

Most people picture Git as a tool that records changes — a stack of diffs layered on top of each other. That mental model is wrong, and it makes Git feel mysterious. Git is really a small key-value database that stores snapshots, and once you see the four object types it uses, commands like reset , checkout , and rebase stop being magic. Git is a content-addressed object store Everything Git tracks lives in .git/objects as an object, and every object has an ID that is the hash of its own content. By default that hash is a 40-character SHA-1 digest (newer Git supports SHA-256). The same bytes always produce the same ID, so the ID is the content's address — change one byte and you get a completely different object. This is why Git data is effectively immutable: you never edit an object in place, you create a new one with a new name. You can look inside any object with git cat-file . The -t flag prints the type, -p pretty-prints the content: $ git cat-file -t 3b18e512 blob $ git cat-file -p 3b18e512 hello world There are exactly four object types: blob , tree , commit , and tag . A blob is just file contents — raw bytes, with no filename and no metadata. The blob for README.md knows nothing about being named README.md ; it only knows what's inside. A tree is a directory listing. It maps names to other objects: each entry has a mode (like a file vs. an executable vs. a subdirectory), a name, and the hash of either a blob (a file) or another tree (a subdirectory). Trees are how Git represents folder structure. Inspecting one shows exactly that: $ git cat-file -p HEAD^ { tree } 100644 blob a906cb... README.md 040000 tree fe8e3b... src A commit ties it together. A commit object points to exactly one top-level tree (the full state of your project at that moment), plus the hash of its parent commit (or parents, for a merge), the author and committer with timestamps, and the commit message. Running git cat-file -p HEAD shows these fields in plain text. Because each commit nam

2026-06-04 原文 →
AI 资讯

MD5 Is Broken — Stop Using It for Passwords (Use SHA256 Instead)

MD5 Is Broken — Stop Using It for Passwords (Use SHA256 Instead) MD5 was invented in 1991. It's 2026, yet I still see developers using MD5 for password hashing in production systems. Let’s break down why this is dangerous and what you should use instead. What Is a Hash Function? A hash function takes any input and produces a fixed-length output called a digest or hash . It is a one-way function , meaning you cannot reverse it to get the original input. Example: ```text id="hash1" Input: "password123" MD5: 482c811da5d5b4bc6d497ffa98491e38 SHA256: ef92b778bafe771e89245b89ecbc08a44a4e166c06659911881f383d4473e94f Even a small input change completely changes the output. --- # Why MD5 Is Broken MD5 generates a **128-bit hash**, which was considered secure decades ago. Today, it's extremely weak. Modern GPUs can compute **billions of MD5 hashes per second**, making brute-force attacks trivial. --- ## The Rainbow Table Problem Attackers use precomputed databases called **rainbow tables**. These tables map common passwords → their hash values. So if you hash: ```text "password123" → MD5 → known value An attacker can instantly look it up. Collision Vulnerabilities Researchers have demonstrated that two different inputs can produce the same MD5 hash . This breaks the core security guarantee of hash functions. SHA256 — The Better Choice SHA256 produces a 256-bit hash and is part of the SHA-2 family. It is currently considered cryptographically secure. Example: ```text id="sha1" "hello" → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 Even tiny changes completely change the output: ```text "hello" → 2cf24dba... "Hello" → 185f8db3... But Wait — Don’t Use SHA256 for Passwords Either This is where many developers make a mistake. SHA256 is not suitable for password hashing . Why? Because it is too fast . Fast hashing allows attackers to brute-force passwords quickly using GPUs. What You Should Use Instead For password storage, use: bcrypt scrypt Argon2 (recommended

2026-06-04 原文 →
产品设计

[Showoff Saturday] I built a real-time collaborative pixel canvas with regional teams

I built a small real-time web experiment called WeSearch Canvas. It’s a shared public pixel canvas where everyone sees the same board and can place one pixel every few seconds. No signup. No feed. No account system. Users are automatically grouped into regional teams, and regions climb the board based on activity. The product idea is simple, but the interesting part for me is the interaction loop: - extremely low-friction entry - real-time shared state - cooldown-based contribution - region/team identity without account creation - social pressure to invite others from your area - canvas archive for past boards I’m trying to keep it lightweight and avoid the usual overbuilt social-app trap. The question is whether the loop is strong enough without accounts, profiles, chat, or notifications. I’d appreciate web/product feedback on: First-load clarity Real-time interaction feel Mobile usability Whether the region mechanic is obvious Any obvious scaling or abuse issues I should plan around early Link: https://wesearch.press/canvas submitted by /u/OGMYT [link] [留言]

2026-06-04 原文 →
AI 资讯

🚀 Building an Online Quiz Platform: My Final Year BCA Project

Hello Developers! 👋 I recently completed my Bachelor of Computer Applications (BCA). For my final-year project, I built an Online Quiz Platform — a web application designed to make both conducting and taking quizzes simple, interactive, and efficient. This project allowed me to apply the concepts I learned throughout my degree and gain practical experience in full-stack web development. 🌐 Live Demo Project Link: nitinsmali / Online_Quiz My final year project is an Online Quiz Web Application designed for an user-friendly experience across devices. 🌐 Online Quiz System 🚀 Live Demo 🔗 https://onlinequiz-project.xo.je/online_quiz/ 🧠 About The Project The Online Quiz System is a full-stack web application designed to provide an interactive and engaging online quiz experience. Users can register, log in, attempt quizzes, track scores, and view leaderboard rankings in real time. This project was developed to strengthen concepts in: Full-Stack Web Development Frontend & Backend Integration Database Management Authentication Systems Hosting & Deployment Real-World Application Flow ✨ Features 🔐 Authentication System User Registration Secure Login System Session Handling Password Management 📚 Quiz Management Category-Based Quizzes Dynamic Questions Timer-Based Quiz System Automatic Score Calculation 🏆 User Performance Leaderboard Rankings User Profile Dashboard Quiz Score Tracking 💬 Feedback System Feedback Submission Database Storage 📱 Responsive UI Mobile-Friendly Design Interactive User Experience Clean Interface 🛠️ Tech Stack Frontend HTML5 CSS3 JavaScript Backend PHP Database MySQL Development Tools XAMPP Git & GitHub Hosting InfinityFree 📂 Project Structure … View on GitHub 📌 Project Overview The Online Quiz Platform is a web-based application that allows users to participate in quizzes, answer multiple-choice questions, and receive instant results. The primary goal of this project was to create a system that eliminates manual quiz evaluation and provides a smooth online

2026-06-04 原文 →
AI 资讯

How I built a multilingual news SPA in vanilla JS — architecture notes

NewsScope is a real-time news search engine: search a topic, filter by language, category and country, get live results from the NewsData.io API. No React, no bundler, no npm dependencies — just HTML, CSS and vanilla ES2020+. This post is about a few specific decisions in the architecture that I think are worth sharing. The module structure The JS is 9 files, each with a single responsibility, loaded in dependency order directly in index.html : config.js → i18n.js → data.js ↓ ↓ ↓ helpers.js → geo.js → ui.js ↓ ↓ ↓ render.js → api.js → main.js Every module only uses things defined in modules loaded before it. main.js registers all event listeners and calls init() — it's the only file that touches everything. config.js is the smallest file in the project, since it only defines the state object and two constants. All app state lives in a single flat object in config.js , accessed as a global: const S = { apiKey : '' , query : '' , activeQuery : '' , language : ' es ' , category : '' , country : '' , results : [], nextPage : null , loading : false , hasSearched : false , error : null , }; No state management library. When something changes, the relevant render function gets called explicitly. Simple, and easy to trace. Translating search intent, not just the UI Most i18n stops at labels and button text. NewsScope has 10 predefined topic shortcuts (AI, Climate, Economy, Cybersecurity…) that trigger a search. If a user picks "Cybersecurity" while the app is set to Japanese, the keyword sent to the API should be in Japanese — not a transliteration of the English word. The solution is a TOPIC_KEYWORDS map in data.js : const TOPIC_KEYWORDS = { ai : { es : ' inteligencia artificial ' , en : ' artificial intelligence ' , ja : ' 人工知能 ' , ar : ' الذكاء الاصطناعي ' , /* 7 more */ }, cyber : { es : ' ciberseguridad ' , en : ' cybersecurity ' , ja : ' サイバーセキュリティ ' , /* 8 more */ }, // 8 more topics }; One string per language, per topic. Switching the UI language and then selecting a

2026-06-04 原文 →
AI 资讯

I built/played with two language tools and it changed how I think about “learning vs translating”

I didn’t expect to care this much about language tools. I started messing around with two different projects, Linguaboard and Parley , mostly out of curiosity. What I got was a surprisingly clear look at two very different ways we interact with language as developers and builders. Linguaboard: translation as exploration, not just output Linguaboard isn’t trying to give you the translation. Instead, it feels more like it’s saying: “Here are several valid ways this could be expressed, pick what fits your intent.” That shift is subtle but important. Most translation tools optimize for a single “correct” answer. Linguaboard leans into ambiguity in a way that actually helps you understand nuance instead of hiding it. I found myself thinking less like: “What does this mean?” and more like: “How should this sound in context?” Parley: learning through interaction, not memorization Parley takes a completely different angle. Instead of treating language as something to decode, it treats it as something to use. You’re not just passively consuming translations, you’re engaging with patterns, context, and recall in a more active loop. What stood out to me is how quickly it shifts you out of “study mode” and into “usage mode.” It feels closer to building intuition than studying rules. The interesting contrast What I didn’t expect is how well these two complement each other: Linguaboard → helps you understand nuance and meaning Parley → helps you internalize and use language One is about interpretation, the other about retention through interaction. Put together, they highlight something a lot of dev tools miss: Language work isn’t one problem. It’s at least two: understanding, and using. Why this matters (especially for devs) If you’re building anything with multilingual UX, AI translation, or global audiences, you’ve probably hit this wall: Translation APIs give you “correct” text But correctness ≠ clarity, tone, or intent These tools made that gap feel very obvious to me. And o

2026-06-04 原文 →
AI 资讯

Premium micro-interactions in React 19 (without the jank)

There's a specific kind of bad animation I notice immediately: the count-up stat that stutters as it ticks, the progress bar that lags a frame behind your scroll, the "active" tab underline that snaps instead of glides. None of it is broken, exactly. It just feels cheap. And nine times out of ten, the cause is the same — the animation is being driven through React state, so every frame triggers a re-render, and the main thread can't keep up. I build motion-heavy interfaces for a living, mostly in Next.js 16 and React 19, and I've landed on a small set of patterns that stay smooth because they bypass React's render loop entirely . They lean on Motion — the library formerly known as Framer Motion. It went independent and got renamed in 2025, so the package is now motion and the import you want is motion/react , not framer-motion ( the APIs are identical, only the import path changed ). Here are three I reach for constantly, plus the reduced-motion discipline that should wrap all of them. The mental model: MotionValues over state The single idea that fixes most jank: a MotionValue is a value Motion tracks outside of React. When it changes, Motion updates the DOM directly via transform or opacity — it does not call setState , so your component doesn't re-render. That's the whole trick. A number ticking from 0 to 4,200 should touch the DOM ~60 times a second and re-render React zero times. If a value changes every frame, it should live in a MotionValue, not in useState . State is for things that change when a user does something; MotionValues are for things that change continuously. Keep that line in your head and the rest of this falls out naturally. 1. A reading-progress bar with useScroll + useSpring The bar at the top of an article that fills as you read. The naive version listens to scroll events and sets state — which is exactly the re-render trap. Motion's useScroll hands you scroll position as a MotionValue already, so there's nothing to re-render. useScroll retu

2026-06-04 原文 →