diff --git a/examples/browserify/main.js b/examples/browserify/main.js
index 46a921a591863..42c640ef09027 100644
--- a/examples/browserify/main.js
+++ b/examples/browserify/main.js
@@ -10,9 +10,6 @@ var pdfPath = '../helloworld/helloworld.pdf';
// Setting worker path to worker bundle.
PDFJS.workerSrc = '../../build/browserify/pdf.worker.bundle.js';
-// It is also possible to disable workers via `PDFJS.disableWorker = true`,
-// however that might degrade the UI performance in web browsers.
-
// Loading a document.
var loadingTask = PDFJS.getDocument(pdfPath);
loadingTask.promise.then(function (pdfDocument) {
diff --git a/examples/learning/helloworld.html b/examples/learning/helloworld.html
index 4142ef6f5a81e..c2988c28707a4 100644
--- a/examples/learning/helloworld.html
+++ b/examples/learning/helloworld.html
@@ -19,13 +19,6 @@
'Hello, world!' example
//
var url = './helloworld.pdf';
- //
- // Disable workers to avoid yet another cross-origin issue (workers need
- // the URL of the script to be loaded, and dynamically loading a cross-origin
- // script does not work).
- //
- // PDFJS.disableWorker = true;
-
//
// The workerSrc property shall be specified.
//
diff --git a/examples/learning/helloworld64.html b/examples/learning/helloworld64.html
index 58890fe87a065..69420495a5340 100644
--- a/examples/learning/helloworld64.html
+++ b/examples/learning/helloworld64.html
@@ -31,12 +31,6 @@ 'Hello, world!' example
'MDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9v' +
'dCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G');
- // Disable workers to avoid yet another cross-origin issue (workers need
- // the URL of the script to be loaded, and dynamically loading a cross-origin
- // script does not work).
- //
- // PDFJS.disableWorker = true;
-
//
// The workerSrc property shall be specified.
//
diff --git a/examples/learning/prevnext.html b/examples/learning/prevnext.html
index 463527a3df1bb..f7e68f2b5d42d 100644
--- a/examples/learning/prevnext.html
+++ b/examples/learning/prevnext.html
@@ -28,14 +28,6 @@ 'Previous/Next' example
//
var url = '../../web/compressed.tracemonkey-pldi-09.pdf';
-
- //
- // Disable workers to avoid yet another cross-origin issue (workers need
- // the URL of the script to be loaded, and dynamically loading a cross-origin
- // script does not work).
- //
- // PDFJS.disableWorker = true;
-
//
// In cases when the pdf.worker.js is located at the different folder than the
// pdf.js's one, or the pdf.js is executed via eval(), the workerSrc property
diff --git a/examples/webpack/main.js b/examples/webpack/main.js
index d0466b86d79d8..d1beb101cb1a4 100644
--- a/examples/webpack/main.js
+++ b/examples/webpack/main.js
@@ -10,9 +10,6 @@ var pdfPath = '../helloworld/helloworld.pdf';
// Setting worker path to worker bundle.
pdfjsLib.PDFJS.workerSrc = '../../build/webpack/pdf.worker.bundle.js';
-// It is also possible to disable workers via `PDFJS.disableWorker = true`,
-// however that might degrade the UI performance in web browsers.
-
// Loading a document.
var loadingTask = pdfjsLib.getDocument(pdfPath);
loadingTask.promise.then(function (pdfDocument) {
diff --git a/external/dist/webpack.js b/external/dist/webpack.js
index f2c4a6400898c..af397943940ea 100644
--- a/external/dist/webpack.js
+++ b/external/dist/webpack.js
@@ -19,8 +19,6 @@ var PdfjsWorker = require('worker-loader!./build/pdf.worker.js');
if (typeof window !== 'undefined' && 'Worker' in window) {
pdfjs.PDFJS.workerPort = new PdfjsWorker();
-} else {
- pdfjs.PDFJS.disableWorker = true;
}
module.exports = pdfjs;
diff --git a/gulpfile.js b/gulpfile.js
index 8300332095466..4d2bdc808d7b3 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -48,7 +48,6 @@ var BASELINE_DIR = BUILD_DIR + 'baseline/';
var MOZCENTRAL_BASELINE_DIR = BUILD_DIR + 'mozcentral.baseline/';
var GENERIC_DIR = BUILD_DIR + 'generic/';
var COMPONENTS_DIR = BUILD_DIR + 'components/';
-var SINGLE_FILE_DIR = BUILD_DIR + 'singlefile/';
var MINIFIED_DIR = BUILD_DIR + 'minified/';
var FIREFOX_BUILD_DIR = BUILD_DIR + 'firefox/';
var CHROME_BUILD_DIR = BUILD_DIR + 'chromium/';
@@ -79,7 +78,6 @@ var DEFINES = {
MOZCENTRAL: false,
CHROME: false,
MINIFIED: false,
- SINGLE_FILE: false,
COMPONENTS: false,
LIB: false,
SKIP_BABEL: false,
@@ -235,10 +233,6 @@ function createBundle(defines) {
var mainAMDName = 'pdfjs-dist/build/pdf';
var mainOutputName = 'pdf.js';
- if (defines.SINGLE_FILE) {
- mainAMDName = 'pdfjs-dist/build/pdf.combined';
- mainOutputName = 'pdf.combined.js';
- }
var mainFileConfig = createWebpackConfig(defines, {
filename: mainOutputName,
@@ -250,9 +244,6 @@ function createBundle(defines) {
.pipe(webpack2Stream(mainFileConfig))
.pipe(replaceWebpackRequire())
.pipe(replaceJSRootName(mainAMDName));
- if (defines.SINGLE_FILE) {
- return mainOutput; // don't need a worker file.
- }
var workerAMDName = 'pdfjs-dist/build/pdf.worker';
var workerOutputName = 'pdf.worker.js';
@@ -634,18 +625,6 @@ gulp.task('components', ['buildnumber'], function () {
]);
});
-gulp.task('singlefile', ['buildnumber'], function () {
- console.log();
- console.log('### Creating singlefile build');
- var defines = builder.merge(DEFINES, { SINGLE_FILE: true, });
-
- var SINGLE_FILE_BUILD_DIR = SINGLE_FILE_DIR + 'build/';
-
- rimraf.sync(SINGLE_FILE_DIR);
-
- return createBundle(defines).pipe(gulp.dest(SINGLE_FILE_BUILD_DIR));
-});
-
gulp.task('minified-pre', ['buildnumber', 'locale'], function () {
console.log();
console.log('### Creating minified viewer');
@@ -1275,9 +1254,7 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
gulp.task('web', ['gh-pages-prepare', 'wintersmith', 'gh-pages-git']);
-gulp.task('dist-pre',
- ['generic', 'singlefile', 'components', 'lib', 'minified'],
- function () {
+gulp.task('dist-pre', ['generic', 'components', 'lib', 'minified'], function() {
var VERSION = getVersionJSON().version;
console.log();
@@ -1359,8 +1336,6 @@ gulp.task('dist-pre',
GENERIC_DIR + 'build/pdf.js.map',
GENERIC_DIR + 'build/pdf.worker.js',
GENERIC_DIR + 'build/pdf.worker.js.map',
- SINGLE_FILE_DIR + 'build/pdf.combined.js',
- SINGLE_FILE_DIR + 'build/pdf.combined.js.map',
SRC_DIR + 'pdf.worker.entry.js',
]).pipe(gulp.dest(DIST_DIR + 'build/')),
gulp.src(MINIFIED_DIR + 'build/pdf.js')
diff --git a/src/display/api.js b/src/display/api.js
index d70014d73a693..2a913d3adecb8 100644
--- a/src/display/api.js
+++ b/src/display/api.js
@@ -46,8 +46,7 @@ var pdfjsFilePath =
var fakeWorkerFilesLoader = null;
var useRequireEnsure = false;
-if (typeof PDFJSDev !== 'undefined' &&
- PDFJSDev.test('GENERIC && !SINGLE_FILE')) {
+if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('GENERIC')) {
// For GENERIC build we need add support of different fake file loaders
// for different frameworks.
if (typeof window === 'undefined') {
@@ -1217,39 +1216,52 @@ var PDFWorker = (function PDFWorkerClosure() {
throw new Error('No PDFJS.workerSrc specified');
}
+ function getMainThreadWorkerMessageHandler() {
+ if (typeof window === 'undefined') {
+ return null;
+ }
+ if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) {
+ return (window.pdfjsNonProductionPdfWorker &&
+ window.pdfjsNonProductionPdfWorker.WorkerMessageHandler);
+ }
+ // PRODUCTION
+ return (window.pdfjsDistBuildPdfWorker &&
+ window.pdfjsDistBuildPdfWorker.WorkerMessageHandler);
+ }
+
let fakeWorkerFilesLoadedCapability;
// Loads worker code into main thread.
function setupFakeWorkerGlobal() {
- var WorkerMessageHandler;
if (fakeWorkerFilesLoadedCapability) {
return fakeWorkerFilesLoadedCapability.promise;
}
fakeWorkerFilesLoadedCapability = createPromiseCapability();
- // In the developer build load worker_loader which in turn loads all the
+
+ let mainWorkerMessageHandler = getMainThreadWorkerMessageHandler();
+ if (mainWorkerMessageHandler) {
+ // The worker was already loaded using a `