Wasm demo
import%20marimo%20as%20mo
mo.md(%0A%20%20%20%20r%22%22%22%0A%20%20%20%20%23%20WASM%20demo%0A%0A%20%20%20%20This%20page%20is%20rendered%20with%20%60mode%3A%20wasm%60.%20Marimo's%20runtime%20loads%0A%20%20%20%20in%20your%20browser%20via%20Pyodide%20on%20first%20paint%20(one-time%20download%0A%20%20%20%20~30%20MB%3B%20subsequent%20visits%20are%20cached).%20Once%20loaded%2C%20the%20slider%0A%20%20%20%20below%20is%20**truly%20reactive**%20%E2%80%94%20no%20precomputed%20lookup%20table%2C%20no%0A%20%20%20%20caps.%20Drag%20continuously%20and%20the%20cell%20below%20recomputes%20Python%0A%20%20%20%20on%20each%20input.%0A%0A%20%20%20%20Compare%20this%20with%20the%20%5BStatic%20reactivity%20demo%5D(precompute_demo.md)%2C%0A%20%20%20%20which%20precomputes%20a%20fixed%20grid%20of%20values%20at%20build%20time%20and%0A%20%20%20%20ships%20zero%20Python%20at%20runtime.%20Both%20approaches%20have%20their%20place%3A%0A%0A%20%20%20%20-%20**Static%20%2B%20precompute**%3A%20instant%20first%20paint%2C%20works%20offline%2C%0A%20%20%20%20%20%20tiny%20page%2C%20but%20limited%20to%20a%20fixed%20value%20grid%20declared%20at%0A%20%20%20%20%20%20author%20time.%20Good%20default.%0A%20%20%20%20-%20**WASM**%3A%20full%20Python%20in%20the%20browser%2C%20every%20cell%20reactive%2C%0A%20%20%20%20%20%20continuous%20sliders%20work%2C%20no%20caps.%20But%20heavy%20first%20paint%20and%0A%20%20%20%20%20%20requires%20the%20user's%20browser%20to%20download%20Pyodide.%0A%0A%20%20%20%20Use%20%60mode%3A%20wasm%60%20per-page%20(in%20%60book.yml%60's%20%60toc%60%20entry)%20for%0A%20%20%20%20chapters%20that%20genuinely%20need%20full%20reactivity.%20Leave%20the%20rest%0A%20%20%20%20static%20for%20fast%20loads.%0A%20%20%20%20%22%22%22%0A)
%23%20Continuous%20slider%20%E2%80%94%20no%20precompute%20caps%20in%20WASM%20mode!%0An%20%3D%20mo.ui.slider(start%3D1%2C%20stop%3D100%2C%20value%3D10%2C%20label%3D%22N%22)%0An
%23%20Live%20computation%20in%20the%20browser%20%E2%80%94%20runs%20every%20time%20%60n%60%20changes.%0Atotal%20%3D%20sum(range(1%2C%20n.value%20%2B%201))%0Aclosed_form%20%3D%20n.value%20*%20(n.value%20%2B%201)%20%2F%2F%202%0Amo.md(%0A%20%20%20%20f%22%22%22%0A%20%20%20%20Sum%20of%201..%7Bn.value%7D%20computed%20live%3A%0A%0A%20%20%20%20-%20Loop%3A%20**%7Btotal%7D**%0A%20%20%20%20-%20Closed%20form%20(n%C2%B7(n%2B1)%2F2)%3A%20**%7Bclosed_form%7D**%0A%20%20%20%20%22%22%22%0A)