Skip to content

Commit 796be64

Browse files
authored
Merge pull request #8148 from QwikDev/computed-only-fire-when-changed
perf: computed signals only trigger when changed
2 parents c673828 + 767c981 commit 796be64

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.changeset/loud-cars-run.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@builder.io/qwik': minor
3+
---
4+
5+
PERF: Computed signals now only trigger listeners if their value has changed

packages/qwik/src/core/use/use-task.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,10 @@ export const runComputed = (
750750
untrack(() => {
751751
const signal = task.$state$! as SignalInternal<unknown>;
752752
signal[QObjectSignalFlags] &= ~SIGNAL_UNASSIGNED;
753-
signal.untrackedValue = returnValue;
754-
signal[QObjectManagerSymbol].$notifySubs$();
753+
if (signal.untrackedValue !== returnValue) {
754+
signal.untrackedValue = returnValue;
755+
signal[QObjectManagerSymbol].$notifySubs$();
756+
}
755757
});
756758
};
757759
const fail = (reason: unknown) => {

packages/qwik/src/server/preload-impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export const preloaderPre = (
6666
* We add modulepreloads even when the script is at the top because they already fire during
6767
* html download
6868
*/
69-
jsx('link', { rel: 'modulepreload', href: preloaderPath, nonce }),
69+
jsx('link', { rel: 'modulepreload', href: preloaderPath, nonce, crossorigin: 'anonymous' }),
7070
jsx('link', {
7171
rel: 'preload',
7272
href: bundleGraphPath,

0 commit comments

Comments
 (0)