diff --git a/services/web/.storybook/preview.js b/services/web/.storybook/preview.js
index 36f92c6dbc..7c3c8a4d19 100644
--- a/services/web/.storybook/preview.js
+++ b/services/web/.storybook/preview.js
@@ -128,3 +128,4 @@ window.user = {
}
window.project_id = 'storybook-project'
+window.showNewPdfPreview = true
diff --git a/services/web/app/views/project/editor.pug b/services/web/app/views/project/editor.pug
index 48a1e98986..5fa6025bed 100644
--- a/services/web/app/views/project/editor.pug
+++ b/services/web/app/views/project/editor.pug
@@ -189,6 +189,7 @@ block append meta
meta(name="ol-showNewLogsUI" data-type="boolean" content=showNewLogsUI)
meta(name="ol-logsUISubvariant" content=logsUISubvariant)
meta(name="ol-showSymbolPalette" data-type="boolean" content=showSymbolPalette)
+ meta(name="ol-showNewPdfPreview" data-type="boolean" content=showNewPdfPreview)
meta(name="ol-enablePdfCaching" data-type="boolean" content=enablePdfCaching)
meta(name="ol-trackPdfDownload" data-type="boolean" content=trackPdfDownload)
meta(name="ol-resetServiceWorker" data-type="boolean" content=resetServiceWorker)
diff --git a/services/web/frontend/js/features/pdf-preview/util/compiler.js b/services/web/frontend/js/features/pdf-preview/util/compiler.js
index 2b2a8693c4..a9cded5350 100644
--- a/services/web/frontend/js/features/pdf-preview/util/compiler.js
+++ b/services/web/frontend/js/features/pdf-preview/util/compiler.js
@@ -51,6 +51,11 @@ export default class DocumentCompiler {
// The main "compile" function.
// Call this directly to run a compile now, otherwise call debouncedAutoCompile.
async compile(options = {}) {
+ // only compile if the feature flag is enabled
+ if (!window.showNewPdfPreview) {
+ return
+ }
+
// set "compiling" to true (in the React component's state), and return if it was already true
let wasCompiling
diff --git a/services/web/frontend/js/shared/context/compile-context.js b/services/web/frontend/js/shared/context/compile-context.js
index 4dc09e5d3d..c08a54003b 100644
--- a/services/web/frontend/js/shared/context/compile-context.js
+++ b/services/web/frontend/js/shared/context/compile-context.js
@@ -172,7 +172,9 @@ export function CompileProvider({ children }) {
// pass the "uncompiled" value up into the scope for use outside this context provider
useEffect(() => {
- setUncompiled(changedAt > 0)
+ if (window.showNewPdfPreview) {
+ setUncompiled(changedAt > 0)
+ }
}, [setUncompiled, changedAt])
// record changes to the autocompile setting
diff --git a/services/web/test/frontend/features/pdf-preview/components/pdf-js-viewer.test.js b/services/web/test/frontend/features/pdf-preview/components/pdf-js-viewer.test.js
index 03d146a7bb..8a8ce9de3e 100644
--- a/services/web/test/frontend/features/pdf-preview/components/pdf-js-viewer.test.js
+++ b/services/web/test/frontend/features/pdf-preview/components/pdf-js-viewer.test.js
@@ -10,6 +10,14 @@ const example = pathToFileURL(
).toString()
describe('', function () {
+ beforeEach(function () {
+ window.showNewPdfPreview = true
+ })
+
+ afterEach(function () {
+ window.showNewPdfPreview = undefined
+ })
+
it('loads all PDF pages', async function () {
renderWithEditorContext()
diff --git a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js
index ae2d17fbf0..0f9235c3a7 100644
--- a/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js
+++ b/services/web/test/frontend/features/pdf-preview/components/pdf-preview.test.js
@@ -149,6 +149,7 @@ describe('', function () {
var clock
beforeEach(function () {
+ window.showNewPdfPreview = true
clock = sinon.useFakeTimers({
shouldAdvanceTime: true,
now: Date.now(),
@@ -157,6 +158,7 @@ describe('', function () {
})
afterEach(function () {
+ window.showNewPdfPreview = undefined
clock.runAll()
clock.restore()
fetchMock.reset()